library(tools)
library(mombf)
library(BAS)
library(tidyverse)
library(stargazer)
library(cowplot)
library(gridGraphics)

PATH = Sys.getenv("BSCA_PATH")
NITER_YRBS = 10; NITER_MCS = 10

source(file.path(PATH,'code/functions.R'))

supplement = list()  # save supplemental figures
plot_path = file.path(PATH, 'data/export/plots')

In this file we pre-process the data, perform a preliminary analysis and create additional results for our main paper “Bayesian Specification Curve Analysis”. Section 1 covers the Youth Risk Behavior Survey (YBRS) dataset, whereas Section 2 covers the Millenium Cohort Study (MCS) dataset. We start with the dataset produced by Orben & Przybylski’s (OP), see the main paper for a reference. The first subsection of each section explains in detail how to reproduce our analysis using the original data, their code and ours. The remaining sections perform the pre- and auxiliary analyses.

To reproduce this file, first set the PATH variable to the project root (folder above the one containing this file). Next, follow the instructions in the two “Generation of data” subsections to prepare the data and compare the MD5 checksums to those in the compiled version of this file (bcsa_preanalysis.html). Finally, knit this file using rmarkdown and the software versions specified in the README.md.

1 YRBS DATA

1.1 DATA PRE-TREATMENT

In this section, we import and treat the data, as well as select relevant variables.

1.1.1 Generation of data

To be able to run this analysis, download the YRBS data, convert it into CSV, save both files to data/yrbs, generate the OP YRBS dataset and save it to data/op_export/1_1_prep_yrbs_data.csv.

We downloaded the latest YRBS data in the MDB format from the CDC on 22 October 2019. We then converted it into a CSV file using Microsoft Access 2019. The files have the following MD5 checksums:

files = c(
  file.path(PATH, 'data/yrbs/yrbs_SADC_2017_National.MDB'), 
  file.path(PATH, 'data/yrbs/yrbs_SADC_2017_National.csv')
)
md5s = md5sum(files)
names(md5s) = basename(files)
md5s
##        yrbs_SADC_2017_National.MDB        yrbs_SADC_2017_National.csv 
## "55d6d502955a2cda631f91930648442a" "e2ceff2b7a093b64bea5c94a42d17723"

We then ran the script 1_1_prep_yrbs.R from OP’s replication files, after adjusting the input and output file paths. The resulting dataset has the following MD5 checksum:

yrbs_path = file.path(PATH,'data/op_export/1_1_prep_yrbs_data.csv')
md5s = md5sum(yrbs_path)
names(md5s) = basename(yrbs_path)
md5s
##             1_1_prep_yrbs_data.csv 
## "0ac7e2fe5e2e0f31a037f9392d84350e"

1.1.2 Import data

Import the data, as generated by OP script. Remove constant variables.

data= read.csv(yrbs_path,header=TRUE)
data= data[, !(colnames(data) %in% c('sitecode','sitename','sitetype','sitetypenum'))]

1.1.3 Treatment variables

x_vars_op= c("q81_n", "q82_n", "tech")
x_names_op= c("TV Use", "Electronic Device Use", "Mean Technology Use")
x= data[,x_vars_op]; names(x)= x_names_op

1.1.4 Outcome variables

Turn the outcome variables into what they say: 0=no, 1=yes.

y_vars_op= c("q26_n", "q27_n", "q28_n", "q29_nd", "q30_nd")
y_names= c("loneliness", "think suicide", "plan suicide", "commit suicide", "doctor suicide")
for (v in y_vars_op) {data[[v]] = 1 - data[[v]]}
y= data[,y_vars_op]; names(y)= y_names

1.1.5 Control variables

Indicate controls used in YRBS study (adolescent’s race) and additional controls. Discretize BMI according to the standard definition.

cvars= c("race_di")
c_names= c("dichotomous race")

data$bmir= cut(data[,'bmi'], breaks=c(0,18.5,25,30,Inf)) #discretize body mass index
levels(data$bmir)= c('underw','normal','overw','obese')
cvarsplus= c("age_n", "sex_n", "grade_n", "year", "bmir")  #survyear same as year

1.1.6 Re-coding variables

Based on the below analyses we make the following adjustments to the variables, as coded and used by OP.

TV usage has a non-monotonic (U-shaped) treatment effect on all outcomes. Discretize the variable into low, medium and high usage, using cut-offs revealed by the linearity analysis.

data$q81_nr= cut(data[,'q81_n'], breaks=c(0,2,6,Inf)) #discretize tv use
levels(data$q81_nr)= c('low', 'medium', 'high')

Normalize the ED usage values to [0, 1], which makes the coefficient more easily interpretable (difference between min and max usage).

data$q82_nr = (data$q82_n - 1)/6

Mean technology use is a linear combination of TV and ED use. Leave it out of the regression.

x_vars= c("q81_nr", "q82_nr")
x_names= c("TV Use", "Electronic Device Use")

Age 12 and 13 have very low number of observations (are very young for grades 9-12). They also have different effects, than age in general (which appears roughly linear). Include them in the regression to control for differential effects at these ages.

data$age12 = data$age_n == 12
data$age13 = data$age_n == 13
for (v in  c('age12', 'age13')) { data[,v]= as.numeric(data[,v]) }

Set commit and doctor to 1 (did not attempt suicide and did not see a doctor about it) if both think and plan are 1 (did not think or plan suicide) to solve a problem with missing values (see below).

y_vars = y_vars_op= c("q26_n", "q27_n", "q28_n", "q29_ndr", "q30_ndr")
data$q29_ndr = data$q29_nd
data$q30_ndr = data$q30_nd

cond= replace_na(data[y_vars[2]] == 1 & data[,y_vars[3]] == 1, FALSE)
data[cond, y_vars[4:5]]= 1
y= data[,y_vars]; names(y)= y_names

1.2 EXPLORATORY DATA ANALYSIS

Format categorical variables as factors.

xf= x
dataf= data

nn= c('TV Use','Electronic Device Use')
for (i in 1:length(nn)) xf[,nn[i]]= factor(xf[,nn[i]])
nn= c('age_n','sex_n','grade_n','year')
for (i in 1:length(nn)) dataf[,nn[i]]= factor(dataf[,nn[i]])

1.2.1 Value counts

Outcomes.

apply(y,2,'table')
##   loneliness think suicide plan suicide commit suicide doctor suicide
## 0      52206         62365        64178          56985          57104
## 1      22090         11932         9741           9032           7747

Treatments.

1 = No usage 2 = Less than 1 hour per day 3 = 1 hour per day 4 = 2 hours per day 5 = 3 hours per day 6 = 4 hours per day 7 = 5 or more hours per day

apply(xf,2,'table')  #table for the treatments
## $`TV Use`
## 
##     1     2     3     4     5     6     7 
##  9223 12466 10615 15580 11566  5762  8118 
## 
## $`Electronic Device Use`
## 
##     1     2     3     4     5     6     7 
## 12669 13517 10638 11902  8924  5202 10519 
## 
## $`Mean Technology Use`
## 
##  1.0  1.5  2.0  2.5  3.0  3.5  4.0  4.5  5.0  5.5  6.0  6.5  7.0 
## 2949 3882 5797 7540 9230 8868 9655 7658 5415 4488 3096 1522 2978

Controls.

apply(dataf[,c(cvars,cvarsplus)],2,'table')  #table for the controls
## $race_di
## 
##     0     1 
## 42410 31133 
## 
## $age_n
## 
##    12    13    14    15    16    17    18 
##   163    84  7608 17325 19038 19032 11497 
## 
## $sex_n
## 
##     0     1 
## 37402 37412 
## 
## $grade_n
## 
##    10    11    12     9 
## 18191 18819 18523 18985 
## 
## $year
## 
##  2007  2009  2011  2013  2015 
## 14041 16410 15425 13583 15624 
## 
## $bmir
## 
## normal  obese  overw underw 
##  43303   7243  13044   6311

1.2.2 Missing values

There are quite a few NA’s for planning/committing suicide, maybe not everyone was asked these questions.

colSums(is.na(y))
##     loneliness  think suicide   plan suicide commit suicide doctor suicide 
##            787            786           1164           9066          10232

This is not an issue with the year; the question was asked in every wave.

dataf[, c('year', 'q29_nd')] %>% group_by(year) %>% summarise(commit_na = sum(is.na(q29_nd)))
year commit_na
2007 1557
2009 1801
2011 1911
2013 1601
2015 3057

Most of the participants who did not answer these questions said they had not thought about or planned a suicide. They may have just skipped the next two questions (about commiting suicide and being treated by a doctor for a suicide attempt).

dataf[, c('q27_n', 'q28_n', 'q29_nd', 'q30_nd')] %>% rename(think= q27_n, plan = q28_n) %>% group_by(think, plan) %>% 
  summarise(commit_na = sum(is.na(q29_nd)), doctor_na = sum(is.na(q30_nd)))
## `summarise()` has grouped output by 'think'. You can override using the `.groups` argument.
think plan commit_na doctor_na
0 0 7347 8318
0 1 322 371
0 NA 76 120
1 0 666 746
1 1 861 971
1 NA 34 47
NA 0 33 39
NA 1 16 20
NA NA 572 571
ywithNA= y
for (i in 1:ncol(ywithNA)) { z= as.character(ywithNA[,i]); z[is.na(z)]= "NA"; ywithNA[,i]= factor(z) }
table(ywithNA[,'plan suicide'], ywithNA[,'commit suicide'])
##     
##          0     1    NA
##   0  54758  1374  8046
##   1   1840  7563   338
##   NA   387    95   682

We solve this by setting commit and doctor to 1 (did not attempt suicide and did not see a doctor about it) if both think and plan are 1 (did not think or plan suicide) above. This solves the NA puzzle.

colSums(is.na(data[,y_vars]))
##   q26_n   q27_n   q28_n q29_ndr q30_ndr 
##     787     786    1164    9066   10232

1.2.3 Correlations

Treatments. Note: Mean use is a linear combination of TV and ED use.

xnum= apply(xf,2,as.numeric)
round(cor(xnum,use='pairwise.complete.obs'),3)
##                       TV Use Electronic Device Use Mean Technology Use
## TV Use                 1.000                 0.207               0.754
## Electronic Device Use  0.207                 1.000               0.798
## Mean Technology Use    0.754                 0.798               1.000

Outcomes.

round(cor(y,use='pairwise.complete.obs'),3)
##                loneliness think suicide plan suicide commit suicide
## loneliness          1.000         0.428        0.372          0.395
## think suicide       0.428         1.000        0.629          0.797
## plan suicide        0.372         0.629        1.000          0.797
## commit suicide      0.395         0.797        0.797          1.000
## doctor suicide      0.384         0.782        0.850          0.923
##                doctor suicide
## loneliness              0.384
## think suicide           0.782
## plan suicide            0.850
## commit suicide          0.923
## doctor suicide          1.000

Controls. Correlation between age and grade is high but not perfect, it may be possible to disentangle the effect of each on wellbeing.

datanum= sapply(c(cvars,cvarsplus), function(z) as.numeric(dataf[,z]))
round(cor(datanum, use='pairwise.complete.obs'),3)
##         race_di  age_n sex_n grade_n   year   bmir
## race_di   1.000  0.001 0.008   0.004  0.013 -0.082
## age_n     0.001  1.000 0.036   0.863 -0.019  0.128
## sex_n     0.008  0.036 1.000   0.003  0.006  0.060
## grade_n   0.004  0.863 0.003   1.000 -0.013  0.110
## year      0.013 -0.019 0.006  -0.013  1.000  0.008
## bmir     -0.082  0.128 0.060   0.110  0.008  1.000

Bivariate pmf to explore the dependence between TV and electronic device use.

ypairs= combn(ncol(y),2)
tab= lapply(1:ncol(ypairs), function(i) table(y[,ypairs[1,i]],y[,ypairs[2,i]]))
names(tab)= sapply(1:ncol(ypairs), function(i) paste(names(y)[ypairs[,i]], collapse=','))
plotxtab(xf[,1], xf[,2], xlab=names(xf)[1], ylab= names(xf)[2])
## Loading required package: MASS
## 
## Attaching package: 'MASS'
## The following object is masked from 'package:dplyr':
## 
##     select
## Loading required package: RColorBrewer

Focus on the two extreme and most frequent categories of electronic device use.

tab= t(table(xf[,1],xf[,2])[,c(1,6)]); tab= 100 * tab/rowSums(tab)  #ISSUE: slight negative association between TV & electronic device use
rownames(tab)= paste(names(xf)[2], '=',c(1,6))
barplot(tab, xlab=names(xf)[1], beside=TRUE, ylab='% adolescents', legend=TRUE)

1.3 LINEARITY OF TREATMENT AND COVARIATE EFFECTS

1.3.1 Outcome 1. Loneliness

idy= 1; idx= c(1,2)
datareg= data.frame(y[,idy], xf[,idx], dataf[,c(cvars,cvarsplus)])
names(datareg)[1]= 'y'
names(datareg)[2:(1+length(idx))]= names(x)[idx]
sel= rowSums(is.na(datareg))==0
datareg= datareg[sel,]

Fit logistic regression model via MLE. Higher TV use associated to less loneliness, higher ED use to more loneliness. The effect of age is mainly from 12 to $$13 years old. There’s higher loneliness at higher grades. Sex has a clear effect. Higher BMI associated to less loneliness (not intuitive why this might be the case).

fit1= glm(y ~ ., data=datareg, family=binomial(link='logit'))
bmle= getci(fit1)
summary(fit1)
## 
## Call:
## glm(formula = y ~ ., family = binomial(link = "logit"), data = datareg)
## 
## Deviance Residuals: 
##    Min      1Q  Median      3Q     Max  
## -1.469  -0.887  -0.669   1.292   2.042  
## 
## Coefficients:
##                           Estimate Std. Error z value Pr(>|z|)    
## (Intercept)               0.117251   0.377848   0.310 0.756322    
## `TV Use`2                -0.063439   0.032119  -1.975 0.048250 *  
## `TV Use`3                -0.233508   0.034062  -6.855 7.11e-12 ***
## `TV Use`4                -0.192136   0.031230  -6.152 7.63e-10 ***
## `TV Use`5                -0.237746   0.033324  -7.134 9.73e-13 ***
## `TV Use`6                -0.199444   0.039965  -4.990 6.02e-07 ***
## `TV Use`7                -0.129120   0.036560  -3.532 0.000413 ***
## `Electronic Device Use`2 -0.094080   0.030132  -3.122 0.001795 ** 
## `Electronic Device Use`3 -0.009967   0.031958  -0.312 0.755129    
## `Electronic Device Use`4  0.076511   0.030899   2.476 0.013280 *  
## `Electronic Device Use`5  0.196857   0.033036   5.959 2.54e-09 ***
## `Electronic Device Use`6  0.351734   0.038589   9.115  < 2e-16 ***
## `Electronic Device Use`7  0.576534   0.031511  18.296  < 2e-16 ***
## race_di                  -0.153805   0.018188  -8.456  < 2e-16 ***
## age_n13                  -0.785938   0.490908  -1.601 0.109379    
## age_n14                  -0.620994   0.376640  -1.649 0.099195 .  
## age_n15                  -0.502233   0.375603  -1.337 0.181177    
## age_n16                  -0.289247   0.375302  -0.771 0.440881    
## age_n17                  -0.203815   0.375452  -0.543 0.587232    
## age_n18                  -0.178269   0.376242  -0.474 0.635632    
## sex_n1                   -0.854301   0.018000 -47.461  < 2e-16 ***
## grade_n10                -0.172331   0.032259  -5.342 9.19e-08 ***
## grade_n11                -0.276281   0.041843  -6.603 4.04e-11 ***
## grade_n12                -0.386364   0.050071  -7.716 1.20e-14 ***
## year2009                 -0.120919   0.027453  -4.405 1.06e-05 ***
## year2011                 -0.060457   0.027876  -2.169 0.030098 *  
## year2013                 -0.078425   0.028905  -2.713 0.006664 ** 
## year2015                 -0.058059   0.028289  -2.052 0.040137 *  
## bmirnormal                0.066453   0.031454   2.113 0.034626 *  
## bmiroverw                 0.155732   0.035835   4.346 1.39e-05 ***
## bmirobese                 0.219424   0.040036   5.481 4.24e-08 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for binomial family taken to be 1)
## 
##     Null deviance: 80469  on 66303  degrees of freedom
## Residual deviance: 77214  on 66273  degrees of freedom
## AIC: 77276
## 
## Number of Fisher Scoring iterations: 4

Graphically. It looks like treatment effects can roughly be captured as linear for ED, but not for TV use (which has a U-shaped effect). BMI, age, grade etc also appear fairly linear.

variables = c(names(x)[idx], cvarsplus)[-4]
plots = list()
for (v in variables) {
  sel= grep(v,rownames(bmle))
  plot(bmle[sel,1],ylim=range(bmle[sel,]), xaxt='n')
  segments(x0=1:length(sel),y0=bmle[sel,2],y1=bmle[sel,3])
  axis(side=1, at=1:length(sel), labels=rownames(bmle)[sel])
  title(v)
}

1.3.2 Outcome 2. Think suicide

idy= 2; idx= c(1,2)
datareg= data.frame(y[,idy], xf[,idx], dataf[,c(cvars,cvarsplus)])
names(datareg)[1]= 'y'
names(datareg)[2:(1+length(idx))]= names(x)[idx]

fit1= glm(y ~ ., data=datareg, family=binomial(link='logit'))
bmle= getci(fit1)
summary(fit1)
## 
## Call:
## glm(formula = y ~ ., family = binomial(link = "logit"), data = datareg)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -1.5945  -0.6355  -0.5172  -0.4210   2.3676  
## 
## Coefficients:
##                           Estimate Std. Error z value Pr(>|z|)    
## (Intercept)               0.194461   0.374606   0.519 0.603686    
## `TV Use`2                -0.156159   0.038815  -4.023 5.74e-05 ***
## `TV Use`3                -0.320939   0.041816  -7.675 1.65e-14 ***
## `TV Use`4                -0.280481   0.037991  -7.383 1.55e-13 ***
## `TV Use`5                -0.284635   0.040553  -7.019 2.24e-12 ***
## `TV Use`6                -0.235128   0.048773  -4.821 1.43e-06 ***
## `TV Use`7                -0.116827   0.043610  -2.679 0.007386 ** 
## `Electronic Device Use`2 -0.048905   0.038118  -1.283 0.199494    
## `Electronic Device Use`3 -0.005226   0.040506  -0.129 0.897343    
## `Electronic Device Use`4  0.117252   0.038685   3.031 0.002438 ** 
## `Electronic Device Use`5  0.204959   0.041139   4.982 6.29e-07 ***
## `Electronic Device Use`6  0.290916   0.047807   6.085 1.16e-09 ***
## `Electronic Device Use`7  0.591975   0.037882  15.627  < 2e-16 ***
## race_di                   0.051404   0.022433   2.291 0.021937 *  
## age_n13                  -1.651279   0.536729  -3.077 0.002094 ** 
## age_n14                  -1.524644   0.372691  -4.091 4.30e-05 ***
## age_n15                  -1.459371   0.371112  -3.932 8.41e-05 ***
## age_n16                  -1.346693   0.370510  -3.635 0.000278 ***
## age_n17                  -1.273160   0.370612  -3.435 0.000592 ***
## age_n18                  -1.345002   0.371956  -3.616 0.000299 ***
## sex_n1                   -0.781669   0.022620 -34.557  < 2e-16 ***
## grade_n10                -0.111711   0.038972  -2.866 0.004151 ** 
## grade_n11                -0.250419   0.051071  -4.903 9.42e-07 ***
## grade_n12                -0.392418   0.061701  -6.360 2.02e-10 ***
## year2009                 -0.070638   0.034778  -2.031 0.042244 *  
## year2011                  0.013969   0.034910   0.400 0.689048    
## year2013                  0.010916   0.035972   0.303 0.761536    
## year2015                  0.093883   0.034843   2.695 0.007049 ** 
## bmirnormal               -0.015476   0.038316  -0.404 0.686277    
## bmiroverw                 0.141643   0.043590   3.249 0.001156 ** 
## bmirobese                 0.343084   0.047738   7.187 6.63e-13 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for binomial family taken to be 1)
## 
##     Null deviance: 58089  on 66302  degrees of freedom
## Residual deviance: 56061  on 66272  degrees of freedom
##   (8780 observations deleted due to missingness)
## AIC: 56123
## 
## Number of Fisher Scoring iterations: 4
variables = c(names(x)[idx], cvarsplus)[-4]
plots = list()
for (v in variables) {
  sel= grep(v,rownames(bmle))
  plot(bmle[sel,1],ylim=range(bmle[sel,]), xaxt='n', ylab='Estimated coefficient')
  segments(x0=1:length(sel),y0=bmle[sel,2],y1=bmle[sel,3])
  axis(side=1, at=1:length(sel), labels=rownames(bmle)[sel])
  title(v)
  if (v == 'TV Use') {
    supplement$lin_tv_think = recordPlot()
  }
}

1.3.3 Outcome 3. Plan suicide

idy= 3; idx= c(1,2)
datareg= data.frame(y[,idy], xf[,idx], dataf[,c(cvars,cvarsplus)])
names(datareg)[1]= 'y'
names(datareg)[2:(1+length(idx))]= names(x)[idx]

fit1= glm(y ~ ., data=datareg, family=binomial(link='logit'))
bmle= getci(fit1)
summary(fit1)
## 
## Call:
## glm(formula = y ~ ., family = binomial(link = "logit"), data = datareg)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -1.3627  -0.5615  -0.4831  -0.3967   2.4206  
## 
## Coefficients:
##                           Estimate Std. Error z value Pr(>|z|)    
## (Intercept)              -0.233590   0.400532  -0.583 0.559759    
## `TV Use`2                -0.219193   0.041850  -5.238 1.63e-07 ***
## `TV Use`3                -0.325690   0.044815  -7.267 3.66e-13 ***
## `TV Use`4                -0.348204   0.041004  -8.492  < 2e-16 ***
## `TV Use`5                -0.340423   0.043733  -7.784 7.02e-15 ***
## `TV Use`6                -0.320691   0.053069  -6.043 1.51e-09 ***
## `TV Use`7                -0.183544   0.046842  -3.918 8.92e-05 ***
## `Electronic Device Use`2 -0.086766   0.041775  -2.077 0.037801 *  
## `Electronic Device Use`3 -0.060600   0.044518  -1.361 0.173435    
## `Electronic Device Use`4  0.073060   0.042266   1.729 0.083885 .  
## `Electronic Device Use`5  0.161474   0.044835   3.602 0.000316 ***
## `Electronic Device Use`6  0.271814   0.051725   5.255 1.48e-07 ***
## `Electronic Device Use`7  0.598322   0.040657  14.716  < 2e-16 ***
## race_di                   0.010429   0.024433   0.427 0.669493    
## age_n13                  -1.573645   0.589823  -2.668 0.007630 ** 
## age_n14                  -1.340033   0.398545  -3.362 0.000773 ***
## age_n15                  -1.282802   0.396873  -3.232 0.001228 ** 
## age_n16                  -1.163473   0.396359  -2.935 0.003331 ** 
## age_n17                  -1.130246   0.396551  -2.850 0.004369 ** 
## age_n18                  -1.178865   0.397991  -2.962 0.003056 ** 
## sex_n1                   -0.624138   0.024398 -25.581  < 2e-16 ***
## grade_n10                -0.101400   0.042175  -2.404 0.016205 *  
## grade_n11                -0.274118   0.055451  -4.943 7.68e-07 ***
## grade_n12                -0.336748   0.067046  -5.023 5.10e-07 ***
## year2009                 -0.061259   0.038475  -1.592 0.111342    
## year2011                  0.062332   0.038267   1.629 0.103340    
## year2013                  0.069808   0.039229   1.779 0.075159 .  
## year2015                  0.161303   0.038076   4.236 2.27e-05 ***
## bmirnormal               -0.005202   0.041765  -0.125 0.900878    
## bmiroverw                 0.103078   0.047598   2.166 0.030342 *  
## bmirobese                 0.305885   0.051917   5.892 3.82e-09 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for binomial family taken to be 1)
## 
##     Null deviance: 50767  on 65973  degrees of freedom
## Residual deviance: 49326  on 65943  degrees of freedom
##   (9109 observations deleted due to missingness)
## AIC: 49388
## 
## Number of Fisher Scoring iterations: 5
variables = c(names(x)[idx], cvarsplus)[-4]
plots = list()
for (v in variables) {
  sel= grep(v,rownames(bmle))
  plot(bmle[sel,1],ylim=range(bmle[sel,]), xaxt='n')
  segments(x0=1:length(sel),y0=bmle[sel,2],y1=bmle[sel,3])
  axis(side=1, at=1:length(sel), labels=rownames(bmle)[sel])
  title(v)
}

1.3.4 Outcome 4. Commit suicide

idy= 4; idx= c(1,2)
datareg= data.frame(y[,idy], xf[,idx], dataf[,c(cvars,cvarsplus)])
names(datareg)[1]= 'y'
names(datareg)[2:(1+length(idx))]= names(x)[idx]

fit1= glm(y ~ ., data=datareg, family=binomial(link='logit'))
bmle= getci(fit1)
summary(fit1)
## 
## Call:
## glm(formula = y ~ ., family = binomial(link = "logit"), data = datareg)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -2.0068  -0.5715  -0.4772  -0.3800   2.5000  
## 
## Coefficients:
##                           Estimate Std. Error z value Pr(>|z|)    
## (Intercept)               1.135614   0.431020   2.635 0.008421 ** 
## `TV Use`2                -0.194494   0.044155  -4.405 1.06e-05 ***
## `TV Use`3                -0.313922   0.047452  -6.616 3.70e-11 ***
## `TV Use`4                -0.316636   0.043275  -7.317 2.54e-13 ***
## `TV Use`5                -0.302101   0.046185  -6.541 6.11e-11 ***
## `TV Use`6                -0.211911   0.055224  -3.837 0.000124 ***
## `TV Use`7                -0.015401   0.048920  -0.315 0.752896    
## `Electronic Device Use`2 -0.157917   0.043531  -3.628 0.000286 ***
## `Electronic Device Use`3 -0.110419   0.046131  -2.394 0.016683 *  
## `Electronic Device Use`4 -0.049058   0.044275  -1.108 0.267846    
## `Electronic Device Use`5  0.070398   0.046832   1.503 0.132784    
## `Electronic Device Use`6  0.164596   0.054154   3.039 0.002370 ** 
## `Electronic Device Use`7  0.480891   0.042479  11.321  < 2e-16 ***
## race_di                  -0.114740   0.025736  -4.458 8.26e-06 ***
## age_n13                  -3.133853   0.677255  -4.627 3.70e-06 ***
## age_n14                  -2.558785   0.428660  -5.969 2.38e-09 ***
## age_n15                  -2.493689   0.426911  -5.841 5.18e-09 ***
## age_n16                  -2.281050   0.426236  -5.352 8.72e-08 ***
## age_n17                  -2.206070   0.426246  -5.176 2.27e-07 ***
## age_n18                  -2.223216   0.427675  -5.198 2.01e-07 ***
## sex_n1                   -0.723560   0.025933 -27.901  < 2e-16 ***
## grade_n10                -0.183183   0.044395  -4.126 3.69e-05 ***
## grade_n11                -0.428616   0.058452  -7.333 2.25e-13 ***
## grade_n12                -0.583331   0.071001  -8.216  < 2e-16 ***
## year2009                 -0.103767   0.040032  -2.592 0.009539 ** 
## year2011                  0.063665   0.039725   1.603 0.109018    
## year2013                  0.034488   0.040988   0.841 0.400115    
## year2015                  0.208038   0.039767   5.231 1.68e-07 ***
## bmirnormal                0.007587   0.043943   0.173 0.862925    
## bmiroverw                 0.153673   0.049928   3.078 0.002085 ** 
## bmirobese                 0.372927   0.054466   6.847 7.54e-12 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for binomial family taken to be 1)
## 
##     Null deviance: 46296  on 59411  degrees of freedom
## Residual deviance: 44584  on 59381  degrees of freedom
##   (15671 observations deleted due to missingness)
## AIC: 44646
## 
## Number of Fisher Scoring iterations: 5

Including age 13 leads to a very large (imprecisely estimated) coefficient in this regression.

variables = c(names(x)[idx], cvarsplus)[-4]
plots = list()
for (v in variables) {
  sel= grep(v,rownames(bmle))
  if (v == 'age_n') sel=sel[-1]
  plot(bmle[sel,1],ylim=range(bmle[sel,]), xaxt='n')
  segments(x0=1:length(sel),y0=bmle[sel,2],y1=bmle[sel,3])
  axis(side=1, at=1:length(sel), labels=rownames(bmle)[sel])
  title(v)
}

1.3.5 Outcome 5. Doctor suicide

idy= 5; idx= c(1,2)
datareg= data.frame(y[,idy], xf[,idx], dataf[,c(cvars,cvarsplus)])
names(datareg)[1]= 'y'
names(datareg)[2:(1+length(idx))]= names(x)[idx]

fit1= glm(y ~ ., data=datareg, family=binomial(link='logit'))
bmle= getci(fit1)
summary(fit1)
## 
## Call:
## glm(formula = y ~ ., family = binomial(link = "logit"), data = datareg)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -1.6275  -0.5342  -0.4495  -0.3580   2.5300  
## 
## Coefficients:
##                          Estimate Std. Error z value Pr(>|z|)    
## (Intercept)               0.18904    0.43867   0.431 0.666510    
## `TV Use`2                -0.21398    0.04669  -4.583 4.58e-06 ***
## `TV Use`3                -0.34028    0.05036  -6.757 1.41e-11 ***
## `TV Use`4                -0.32136    0.04574  -7.025 2.13e-12 ***
## `TV Use`5                -0.33165    0.04911  -6.753 1.44e-11 ***
## `TV Use`6                -0.23572    0.05894  -3.999 6.35e-05 ***
## `TV Use`7                -0.02023    0.05184  -0.390 0.696343    
## `Electronic Device Use`2 -0.12245    0.04649  -2.634 0.008448 ** 
## `Electronic Device Use`3 -0.10660    0.04956  -2.151 0.031493 *  
## `Electronic Device Use`4 -0.03699    0.04744  -0.780 0.435593    
## `Electronic Device Use`5  0.10394    0.04985   2.085 0.037070 *  
## `Electronic Device Use`6  0.16698    0.05789   2.885 0.003919 ** 
## `Electronic Device Use`7  0.51062    0.04514  11.313  < 2e-16 ***
## race_di                  -0.01424    0.02726  -0.522 0.601511    
## age_n13                  -2.25261    0.68276  -3.299 0.000969 ***
## age_n14                  -1.87280    0.43612  -4.294 1.75e-05 ***
## age_n15                  -1.82909    0.43430  -4.212 2.54e-05 ***
## age_n16                  -1.65817    0.43385  -3.822 0.000132 ***
## age_n17                  -1.59442    0.43417  -3.672 0.000240 ***
## age_n18                  -1.61010    0.43592  -3.694 0.000221 ***
## sex_n1                   -0.71767    0.02766 -25.945  < 2e-16 ***
## grade_n10                -0.13464    0.04722  -2.851 0.004357 ** 
## grade_n11                -0.37488    0.06241  -6.007 1.89e-09 ***
## grade_n12                -0.49513    0.07580  -6.532 6.50e-11 ***
## year2009                 -0.06231    0.04319  -1.443 0.149114    
## year2011                  0.13377    0.04290   3.119 0.001817 ** 
## year2013                  0.11466    0.04389   2.612 0.008996 ** 
## year2015                  0.30047    0.04248   7.073 1.52e-12 ***
## bmirnormal                0.01361    0.04673   0.291 0.770806    
## bmiroverw                 0.15285    0.05314   2.876 0.004023 ** 
## bmirobese                 0.39797    0.05770   6.897 5.30e-12 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for binomial family taken to be 1)
## 
##     Null deviance: 41872  on 58470  degrees of freedom
## Residual deviance: 40364  on 58440  degrees of freedom
##   (16612 observations deleted due to missingness)
## AIC: 40426
## 
## Number of Fisher Scoring iterations: 5
variables = c(names(x)[idx], cvarsplus)[-4]
plots = list()
for (v in variables) {
  sel= grep(v,rownames(bmle))
  if (v == 'age_n') sel=sel[-1]
  plot(bmle[sel,1],ylim=range(bmle[sel,]), xaxt='n')
  segments(x0=1:length(sel),y0=bmle[sel,2],y1=bmle[sel,3])
  axis(side=1, at=1:length(sel), labels=rownames(bmle)[sel])
  title(v)
}

1.4 REGRESSION ANALYSIS

Issues with Orben’s et al analysis

  1. Orben et al run linear regression, but all 5 outcomes are discrete

  2. Sex and grade highly significant, but ignored in OP’s analysis

1.4.1 Graphical parameters

Use the re-defined treatment variables (see data pre-treatment).

x= data[,x_vars]; names(x)= x_names

Include one year coefficient in the control variable panel and set readable names for treatments and controls. Include year dummies but only show them as one variable in the BSCA. Include dummies for ages 12 and 13, to control for effects of these students being misaligned with their grade.

cvars= "race_di"
cvarsplus= c("age12", "age13", "age_n", "sex_n", "grade_n", "year", "bmi")
c_names = c('Race', 'Aged 12', 'Aged 13', 'Age', 'Male', 'Grade', 'Year', 'BMI')

data[,'year']= factor(data[,'year'])  # keep year as a factor
id_years=c(12:14)  # hide all but one year coefficient (same variable -> included together)

x_labels = c('TV use: medium', 'TV use: high', 'Electronic device use')
var_labels = c_names

Transform the y labels into the odds ratio (from min=0 to max=1), by exponentiating the coefficient.

y_labels = seq(0.8, 2, 0.2); names(y_labels) = log(y_labels)

Only show 50 models and decrease the size of the legend to nicely combine in the grid figure.

maxmodels = 50
legend_size = 1

1.4.2 Outcome 1. Loneliness

Regress the first outcome (loneliness) on the two treatments. Store the data in datareg.

idy= 1; idx= c(1,2)
datareg= data.frame(y[,idy], x[,idx], data[,c(cvars,cvarsplus)])
names(datareg) = c('y', names(x)[idx], c_names)
sel= rowSums(is.na(datareg))==0
datareg= datareg[sel,]

Fit logistic regression model via MLE. Higher TV use associated to less loneliness, higher ED use to more loneliness. The effect of age is mainly from 12 to $$13 years old. There’s higher loneliness at higher grades. Sex has a clear effect. Higher BMI associated to less loneliness (not intuitive why this might be the case).

reg= y ~ . 
fit1= glm(reg, data=datareg, family=binomial(link='logit'))
bmle= getci(fit1)
summary(fit1)
## 
## Call:
## glm(formula = reg, family = binomial(link = "logit"), data = datareg)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -1.6353  -0.8806  -0.6784   1.2890   2.0571  
## 
## Coefficients:
##                          Estimate Std. Error z value Pr(>|z|)    
## (Intercept)             -1.409322   0.128734 -10.948  < 2e-16 ***
## `TV Use`medium          -0.198743   0.019707 -10.085  < 2e-16 ***
## `TV Use`high            -0.078471   0.031469  -2.494   0.0126 *  
## `Electronic Device Use`  0.599879   0.027129  22.112  < 2e-16 ***
## Race                    -0.168150   0.017986  -9.349  < 2e-16 ***
## `Aged 12`                0.872162   0.379710   2.297   0.0216 *  
## `Aged 13`               -0.042573   0.317175  -0.134   0.8932    
## Age                      0.116986   0.014841   7.882 3.21e-15 ***
## Male                    -0.866052   0.017922 -48.323  < 2e-16 ***
## Grade                   -0.120497   0.016110  -7.480 7.45e-14 ***
## Year2009                -0.123163   0.027432  -4.490 7.13e-06 ***
## Year2011                -0.064442   0.027838  -2.315   0.0206 *  
## Year2013                -0.064158   0.028811  -2.227   0.0260 *  
## Year2015                -0.033438   0.028102  -1.190   0.2341    
## BMI                      0.012493   0.001723   7.252 4.10e-13 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for binomial family taken to be 1)
## 
##     Null deviance: 80469  on 66303  degrees of freedom
## Residual deviance: 77346  on 66289  degrees of freedom
## AIC: 77376
## 
## Number of Fisher Scoring iterations: 4

Run EBIC-based model selection. This is an approximation to Bayesian model selection under the unit information prior, and BetaBin(1,1) on the model space. Unfortunately for logistic regression this uses a slowish R implementation. We set includevars=1 to force the inclusion of the intercept.

ms= mombf:::modelSelectionGLM(reg, data=datareg, includevars=1, familyglm= binomial(link='logit'), priorDelta=modelbbprior(1,1))
## Enumerating 1024 models..........

Most posterior probability is assigned to the 2 top models, i.e. there’s little uncertainty on what variables should be included.

pp= postProb(ms)
head(pp)
modelid family pp
926 1,2,3,4,5,8,9,10,15 binomial logit 0.8742234
990 1,2,3,4,5,6,8,9,10,15 binomial logit 0.1131518
958 1,2,3,4,5,7,8,9,10,15 binomial logit 0.0103517
1022 1,2,3,4,5,6,7,8,9,10,15 binomial logit 0.0022227
928 1,2,3,4,5,8,9,10,11,12,13,14,15 binomial logit 0.0000404
992 1,2,3,4,5,6,8,9,10,11,12,13,14,15 binomial logit 0.0000089

We obtain BMA estimates, 95% posterior intervals and marginal posterior inclusion probabilities. Both TV and ED use have very high posterior prob. Similarly strong evidence for including sex, grade and bmi. Small post prob to race, the adjustment variable considered by Orben et al. Age and year are dropped.

b= coef(ms)
b
##                              estimate         2.5%       97.5%       margpp
## (Intercept)             -1.441659e+00 -1.690104818 -1.19286256 1.000000e+00
## `TV Use`medium          -2.005901e-01 -0.239062280 -0.16249278 1.000000e+00
## `TV Use`high            -7.880829e-02 -0.140010147 -0.01713051 1.000000e+00
## `Electronic Device Use`  6.034143e-01  0.551856512  0.65637300 1.000000e+00
## Race                    -1.675038e-01 -0.202968973 -0.13263115 1.000000e+00
## `Aged 12`                9.763232e-02  0.000000000  1.17053596 1.153838e-01
## `Aged 13`               -1.092674e-03  0.000000000  0.00000000 1.257559e-02
## Age                      1.118438e-01  0.083224218  0.14050808 1.000000e+00
## Male                    -8.653192e-01 -0.900475527 -0.83084152 1.000000e+00
## Grade                   -1.157834e-01 -0.146725928 -0.08458646 1.000000e+00
## Year2009                -1.564692e-05  0.000000000  0.00000000 5.040349e-05
## Year2011                -7.833472e-06  0.000000000  0.00000000 5.040349e-05
## Year2013                -9.228734e-06  0.000000000  0.00000000 5.040349e-05
## Year2015                -8.685394e-06  0.000000000  0.00000000 5.040349e-05
## BMI                      1.277104e-02  0.009421761  0.01616065 1.000000e+00

Odds-ratios help characterize the practical importance of the estimated treatment effects (use getOR defined in functions.R for convenience).

getOR(b, treat='TV Use') %>% format(digits=2, scientific=FALSE) # medium and high treatments
##                OR     CI.low CI.up 
## `TV Use`medium "0.82" "0.79" "0.85"
## `TV Use`high   "0.92" "0.87" "0.98"
getOR(b, treat='Electronic', treatvals=round((1:6)/6, 2)) %>% format(digits=3, scientific=FALSE) #increasing treatment by 1,...,6 units
##                 OR     CI.low CI.up 
## Electronic 0.17 "1.11" "1.10" "1.12"
## Electronic 0.33 "1.22" "1.20" "1.24"
## Electronic 0.5  "1.35" "1.32" "1.39"
## Electronic 0.67 "1.50" "1.45" "1.55"
## Electronic 0.83 "1.65" "1.58" "1.72"
## Electronic 1    "1.83" "1.74" "1.93"

We could obtain parameter estimates and posterior intervals for the top 100 models.

bmodels= coefByModel(ms, maxmodels=100, alpha=0.05)

sel= "`Electronic Device Use`"
bsel= cbind(postmean=bmodels$postmean[,sel],ci.low=bmodels$ci.low[,sel],ci.up=bmodels$ci.up[,sel])
head(round(bsel,3))

Produce the BMA SCA plots. Clearly TV and ED use have effects of opposing signs.

idx_fit=c(2:4) 
single_bsca(ms, coefidx=idx_fit, omitvars=c(1, idx_fit, id_years), x.labels=x_labels, var.labels=var_labels, y.labels=y_labels, maxmodels=maxmodels, legend.cex=legend_size)

# save the plot
bscas = list()
bscas[[idy]] = recordPlot()

1.4.3 Outcome 2. Think suicide

idy= 2; idx= c(1,2); idx_fit=c(2:4) 
reg= y ~ . 

datareg= data.frame(y[,idy], x[,idx], data[,c(cvars,cvarsplus)])
names(datareg)[1]= 'y'
names(datareg)[2:(1+length(idx))]= names(x)[idx]
sel= rowSums(is.na(datareg))==0
datareg= datareg[sel,]

ms= mombf:::modelSelectionGLM(reg, data=datareg, includevars=1, familyglm= binomial(link='logit'), priorDelta=modelbbprior(1,1))
## Enumerating 1024 models..........
b= coef(ms)

getOR(b, treat='TV Use') %>% format(digits=2, scientific=FALSE) # medium and high treatments
##                OR     CI.low CI.up 
## `TV Use`medium "0.79" "0.76" "0.83"
## `TV Use`high   "0.95" "0.89" "1.03"
getOR(b, treat='Electronic', treatvals=round((1:6)/6, 2)) %>% format(digits=3, scientific=FALSE) #increasing treatment by 1,...,6 units
##                 OR     CI.low CI.up 
## Electronic 0.17 "1.11" "1.10" "1.13"
## Electronic 0.33 "1.23" "1.20" "1.26"
## Electronic 0.5  "1.37" "1.33" "1.41"
## Electronic 0.67 "1.52" "1.46" "1.59"
## Electronic 0.83 "1.69" "1.60" "1.78"
## Electronic 1    "1.88" "1.76" "2.00"
single_bsca(ms, coefidx=idx_fit, omitvars=c(1, idx_fit, id_years), x.labels=x_labels, var.labels=var_labels, y.labels=y_labels, maxmodels=maxmodels, legend.cex=legend_size)

bscas[[idy]] = recordPlot()

1.4.4 Outcome 3. Plan suicide

idy= 3; idx= c(1,2); idx_fit=c(2:4) 
reg= y ~ . 

datareg= data.frame(y[,idy], x[,idx], data[,c(cvars,cvarsplus)])
names(datareg)[1]= 'y'
names(datareg)[2:(1+length(idx))]= names(x)[idx]
sel= rowSums(is.na(datareg))==0
datareg= datareg[sel,]

ms= mombf:::modelSelectionGLM(reg, data=datareg, includevars=1, familyglm= binomial(link='logit'), priorDelta=modelbbprior(1,1))
## Enumerating 1024 models..........
b= coef(ms)

getOR(b, treat='TV Use') %>% format(digits=2, scientific=FALSE) # medium and high treatments
##                OR     CI.low CI.up 
## `TV Use`medium "0.79" "0.75" "0.83"
## `TV Use`high   "0.96" "0.89" "1.04"
getOR(b, treat='Electronic', treatvals=round((1:6)/6, 2)) %>% format(digits=3, scientific=FALSE) #increasing treatment by 1,...,6 units
##                 OR     CI.low CI.up 
## Electronic 0.17 "1.11" "1.10" "1.12"
## Electronic 0.33 "1.22" "1.20" "1.25"
## Electronic 0.5  "1.36" "1.31" "1.41"
## Electronic 0.67 "1.51" "1.44" "1.58"
## Electronic 0.83 "1.67" "1.57" "1.77"
## Electronic 1    "1.85" "1.72" "1.98"
single_bsca(ms, coefidx=idx_fit, omitvars=c(1, idx_fit, id_years), x.labels=x_labels, var.labels=var_labels, y.labels=y_labels, maxmodels=maxmodels, legend.cex=legend_size)

bscas[[idy]] = recordPlot()

1.4.5 Outcome 4. Commit suicide

idy= 4; idx= c(1,2); idx_fit=c(2:4) 
reg= y ~ . 

datareg= data.frame(y[,idy], x[,idx], data[,c(cvars,cvarsplus)])
names(datareg)[1]= 'y'
names(datareg)[2:(1+length(idx))]= names(x)[idx]
sel= rowSums(is.na(datareg))==0
datareg= datareg[sel,]

ms= mombf:::modelSelectionGLM(reg, data=datareg, includevars=1, familyglm= binomial(link='logit'), priorDelta=modelbbprior(1,1))
## Enumerating 1024 models..........
b= coef(ms)

getOR(b, treat='TV Use') %>% format(digits=2, scientific=FALSE) # medium and high treatments
##                OR     CI.low CI.up 
## `TV Use`medium "0.81" "0.76" "0.85"
## `TV Use`high   "1.12" "1.03" "1.22"
getOR(b, treat='Electronic', treatvals=round((1:6)/6, 2)) %>% format(digits=3, scientific=FALSE) #increasing treatment by 1,...,6 units
##                 OR     CI.low CI.up 
## Electronic 0.17 "1.09" "1.08" "1.11"
## Electronic 0.33 "1.19" "1.16" "1.22"
## Electronic 0.5  "1.30" "1.25" "1.34"
## Electronic 0.67 "1.41" "1.35" "1.49"
## Electronic 0.83 "1.54" "1.45" "1.63"
## Electronic 1    "1.68" "1.56" "1.81"
single_bsca(ms, coefidx=idx_fit, omitvars=c(1, idx_fit, id_years), x.labels=x_labels, var.labels=var_labels, y.labels=y_labels, maxmodels=maxmodels, legend.cex=legend_size)

bscas[[idy]] = recordPlot()

1.4.6 Outcome 5. Doctor suicide

idy= 5; idx= c(1,2); idx_fit=c(2:4) 
reg= y ~ . 

datareg= data.frame(y[,idy], x[,idx], data[,c(cvars,cvarsplus)])
names(datareg)[1]= 'y'
names(datareg)[2:(1+length(idx))]= names(x)[idx]
sel= rowSums(is.na(datareg))==0
datareg= datareg[sel,]

ms= mombf:::modelSelectionGLM(reg, data=datareg, includevars=1, familyglm= binomial(link='logit'), priorDelta=modelbbprior(1,1))
## Enumerating 1024 models..........
b= coef(ms)

getOR(b, treat='TV Use') %>% format(digits=2, scientific=FALSE) # medium and high treatments
##                OR     CI.low CI.up 
## `TV Use`medium "0.80" "0.76" "0.85"
## `TV Use`high   "1.14" "1.04" "1.24"
getOR(b, treat='Electronic', treatvals=round((1:6)/6, 2)) %>% format(digits=3, scientific=FALSE) #increasing treatment by 1,...,6 units
##                 OR     CI.low CI.up 
## Electronic 0.17 "1.10" "1.08" "1.11"
## Electronic 0.33 "1.19" "1.16" "1.23"
## Electronic 0.5  "1.31" "1.26" "1.36"
## Electronic 0.67 "1.43" "1.36" "1.51"
## Electronic 0.83 "1.56" "1.46" "1.67"
## Electronic 1    "1.71" "1.58" "1.86"
single_bsca(ms, coefidx=idx_fit, omitvars=c(1, idx_fit, id_years), x.labels=x_labels, var.labels=var_labels, y.labels=y_labels, maxmodels=maxmodels, legend.cex=legend_size)

bscas[[idy]] = recordPlot()

1.4.7 Combine figures

Combine all outcomes not featured in the main analysis into a single graph shown in the supplement.

supplement$bsca_other = plot_grid(plotlist=bscas[-2], ncol=2, labels='auto')
ggsave(
  file.path(plot_path, 'yrbs_bsca_other.png'), 
  supplement$bsca_other,
  height=6, width=8
)
supplement$bsca_other

1.5 ROBUSTNESS CHECKS

1.5.1 Only one TV coefficient

data$q81_nra = (data$q81_n - 1)/6

idy= 2; idx= c(1,2); idx_fit_num=c(2:3) 
x_labels_num = c('TV use', 'Electronic device use')
reg= y ~ . 

datareg= data.frame(y[,idy], data[,c('q81_nra', 'q82_nr')], data[,c(cvars,cvarsplus)])
names(datareg)[1]= 'y'
names(datareg)[2:(1+length(idx))]= names(x)[idx]
sel= rowSums(is.na(datareg))==0
datareg= datareg[sel,]

ms= mombf:::modelSelectionGLM(reg, data=datareg, includevars=1, familyglm= binomial(link='logit'), priorDelta=modelbbprior(1,1))
## Enumerating 1024 models..........
single_bsca(ms, coefidx=idx_fit_num, omitvars=c(1, idx_fit_num, id_years), x.labels=x_labels_num, var.labels=var_labels, y.labels=y_labels)

supplement$bsca_tv_num = recordPlot()

1.5.2 Linear regression

Not implemented in mombf, use BAS.

# regression parameters
idy= 2; idx= c(1,2); idx_fit=c(2:4) 
reg= y ~ . 
datareg= data.frame(y[,idy], x[,idx], data[,c(cvars,cvarsplus)])
names(datareg)[1]= 'y'
names(datareg)[2:(1+length(idx))]= names(x)[idx]
sel= rowSums(is.na(datareg))==0
datareg= datareg[sel,]

# regression 
ms = BAS:::bas.lm(
  reg, data=datareg,
  prior='BIC', modelprior=beta.binomial()
)

# bsca
single_bsca(ms, coefidx=idx_fit, omitvars=c(1, idx_fit, id_years), x.labels=x_labels, var.labels=var_labels)

supplement$bsca_lin = recordPlot()

1.6 SUBGROUP ANALYSIS

We perform a gender subgroup analysis. The variables are parameterized as described in the paper. Interaction terms are included only if the corresponding main variable is included. BMA is done through Gibbs sampling.

idx=c(1,2); idg="Male"
{
  options(na.action='na.pass')
  x.reg = model.matrix(~ ., x[,idx])[, -1]
  colnames(x.reg) = x_labels
}
ms_inter = list(); coef_inter = list()

for (idy in 1:length(y_vars)) {
  yname = y_names[idy]
  message(yname)
  
  datareg = na.omit(data.frame(y[,idy], x.reg, data[,c(cvars,cvarsplus)]))
  names(datareg) = c('y', colnames(x.reg), c_names)
  
  # treatments
  idt = colnames(x.reg)
  datareg[idt] = datareg[idt] - 1/2
  # group
  g = datareg[[idg]]; rho = sum(g == 1)/length(g)
  datareg[[idg]] = ifelse(g == 1, 1-rho, -rho)
  # interaction 
  inter = datareg[idt]*datareg[[idg]]
  colnames(inter) = paste0(colnames(inter), " × male")
  
  d = mombf:::createDesign(y ~ ., cbind(datareg, inter))
  p=length(d$constraints); pi=ncol(inter)
  d$constraints[(p-pi+1):p] = 1:pi+1
  ms_inter[[yname]] = mombf:::modelSelection(
    d$y, d$x, includevars=1, family="binomial", 
    priorDelta=modelbbprior(1,1), priorCoef=bicprior(), priorGroup=bicprior(),
    niter=NITER_YRBS, groups=d$groups, constraints=d$constraints,
  )
  coef_inter[[yname]] = coef(ms_inter[[yname]])
}
## loneliness
## Greedy searching posterior mode... Done.
## Running Gibbs sampler........... Done.
## think suicide
## Greedy searching posterior mode... Done.
## Running Gibbs sampler........... Done.
## plan suicide
## Greedy searching posterior mode... Done.
## Running Gibbs sampler........... Done.
## commit suicide
## Greedy searching posterior mode... Done.
## Running Gibbs sampler........... Done.
## doctor suicide
## Greedy searching posterior mode... Done.
## Running Gibbs sampler........... Done.

We can never rule out a zero gender effect.

supplement$mbsca_inter = multi_bsca(
  coef_inter, ms=ms_inter, conversion=exp,  y.scale='Odds ratio', 
  treatments=tail(rownames(coef_inter$loneliness), n=length(x_labels)),
)
supplement$mbsca_inter

1.7 SAVE DATA

Save the data for use in bsca_main.Rmd.

save(
  data, x_vars, x_names, x_labels, x, y_vars, y_names, y, cvars, cvarsplus, c_names, supplement,
  file=file.path(PATH, 'data/export/yrbs.Rdata')
)

2 MCS DATA

# clean up the R environment
rm(list=setdiff(ls(), c('PATH', 'plot_path', 'NITER_MCS')))
source(file.path(PATH,'code/functions.R'))
supplement = list()  # save supplemental figures

2.1 DATA PRE-TREATMENT

In this section, we import and treat the data, as well as select relevant variables.

2.1.1 Generation of data

To be able to run this analysis, download the MCS6 data to data/mcs/tab, generate the OP MCS dataset and save it to data/op_export/1_3_prep_mcs_data.csv.

We downloaded the MCS6 data (4th edition) from the UK data service on 22 October 2019 in the CSV format. The files have the following MD5 checksums:

files = file.path(PATH, 'data/mcs/tab') 
md5s = md5sum(list.files(files, full.names=TRUE))
names(md5s) = list.files(files)
md5s
##          mcs_sweep6_imd_e_2004.tab          mcs_sweep6_imd_n_2004.tab 
## "2cb412cb28a9a800478a64379164caf4" "d399f0b702772ea874792de40c2f58ed" 
##          mcs_sweep6_imd_s_2004.tab          mcs_sweep6_imd_w_2004.tab 
## "3fb9fadf7b122f6d1c35d62d80baeddc" "e68df41a3d7b9305f2e5e26ca37de812" 
##  mcs6_cm_accelerometer_derived.tab             mcs6_cm_assessment.tab 
## "efc4e349ad436a9a845f8a6463aa8223" "15cecba5812cf7ecfa4ba76ba6464718" 
##                mcs6_cm_derived.tab              mcs6_cm_interview.tab 
## "501f62c9b2488557b0356aa6e9a17735" "7a23f6475bfe4d8aaa5415ab8edd1780" 
##            mcs6_cm_measurement.tab         mcs6_cm_tud_harmonised.tab 
## "91cc5f7df44def30877dbdb9182bccaf" "d901c7414653438e2677ffc622ddda42" 
##            mcs6_family_derived.tab                    mcs6_hhgrid.tab 
## "575dc6452ac7382b57fe301ad50c1679" "29e593b1372b7a247051b1d5e90f231e" 
##         mcs6_parent_assessment.tab       mcs6_parent_cm_interview.tab 
## "a3650984175178de60b1290f971c3252" "d4de9758d8af357379f29ee52b630aab" 
##            mcs6_parent_derived.tab    mcs6_parent_income_brackets.tab 
## "a0931ffda2de9804b01a5e119a29f7ca" "67983aa242f6cbb44855bb745bab97ed" 
##          mcs6_parent_interview.tab   mcs6_proxy_partner_interview.tab 
## "c479e0cc95420615629a7a9a11d44586" "9e33ba291d9b807b37770be742e7c6cc"

We then ran the script 1_3_prep_mcs.R from OP’s replication files. The resulting dataset has the following MD5 checksum:

mcs_path = file.path(PATH, 'data/op_export/1_3_prep_mcs_data.csv')
md5s = md5sum(mcs_path)
names(md5s) = basename(mcs_path)
md5s
##              1_3_prep_mcs_data.csv 
## "ef530fc3cb844e89f1e752ab7f41e38b"

Note: we used a newer version of the MCS dataset than OP. The results generated by the OP script 2_3_sca_mcs.R using these data (placed into data/op_export) differ somewhat from those provided by OP in their repository (placed into data/op_results).

mcs_files = c(
  'data/op_export/2_3_sca_mcs_results_cm.rda',
  'data/op_results/2_3_sca_mcs_results_cm.rda'
)

md5s = md5sum(file.path(PATH, mcs_files))
md5s = cbind(md5s, file.info(file.path(PATH, mcs_files))[c('size')])
rownames(md5s) = mcs_files
md5s
md5s size
data/op_export/2_3_sca_mcs_results_cm.rda bd5e5f0389db4792e16c3d4171231212 462725
data/op_results/2_3_sca_mcs_results_cm.rda 76fa21b2a56b2547fdb5f6228b79a2d7 462623

2.1.2 Import data

data= read.csv(mcs_path,header=TRUE)
data= data[, !(colnames(data) %in% c('X'))] #Remove extra ID

2.1.3 Treatment variables

The data were heavily transformed by OP. We go over the coding and potential issues by the type of variable (treatment/outcome/control).

Original MCS scales:

  • TV, games, internet, social media: 1=“None”, 2=“0-0.5 hours”, 3=“0.5-1 hour”, 4=“1-2 hours”, …, 8=“>7 hours”
  • Own PC: 1=“Yes”, 2=“No”

OP scales:

  • TV, games, internet, social media: linear transformation to 1-10
  • Own PC: 1=“No”, 10=“Yes”

Since social media and internet usage are highly co-linear, we use “other internet”, with social media usage time removed (approximately), and store it in data$fcinth00rm.

internet_vars = data[,c("fcsome00r", "fcinth00r")]
names(internet_vars) = c('Social media', 'Internet')
round(cor(internet_vars, use='pairwise.complete.obs'),3)
##              Social media Internet
## Social media        1.000    0.538
## Internet            0.538    1.000
data$fcinth00rm = ifelse(
  data$fcinth00r - data$fcsome00r + 1 > 1,
  data$fcinth00r - data$fcsome00r + 1,
  0
)

This gives us the following possible treatment variables.

x_vars= c(
  "fctvho00r", "fccomh00r", "fcsome00r", "fcinth00rm", "fccmex00r"
) 
x_names= c(
  "TV", "Electronic games", "Social media", "Other internet", "Own computer"
) 

As with the YRBS data, we normalize ordinary treatment values to [0, 1], which makes the regression coefficient more easily interpretable (difference between min and max usage).

for (v in x_vars) { data[[v]]= (data[[v]] - 1)/9 }
x= data[,x_vars]; names(x)= x_names

2.1.4 Outcome variables

Original MCS scales:

  • Depressive symptoms (Mood and Feelings Questionnaire – short version; SMFQ): 1=“Not true”, 2=“Sometimes”, 3=“True”
  • Self-esteem (Rosenberg, positive only): 1=“Strongly agree”, 2=“Agree”, 3=“Disagree”, 4=“Strongly disagree” (should be the opposite)
  • Well-being: 1=“Completely happy”, …, 7=“Not happy at all”
  • Strengths and Difficulties Questionnaire (SDQ) single: 1=“Not true”, 2=“Somewhat true”, 3=“Certainly true”
  • SDQ means [total]: 0-10 [0-40] from summing 5 [20] questions’ raw score (above - 1)

OP scales:

  • Generally: linear transformation to 1-10 where 1=“lowest well being”, 10=“highest well being”
  • SDQ single: -1=“lowest well being”, 1=“highest well being”
  • SDQ prosocial mean: 0=“lowest well being”, 10=“highest well being”
  • SDQ other means: 1=“lowest well being”, 11=“highest well being”
  • SDQ total: 1=“lowest well being”, 41=“highest well being”
# Cohort member: 1. Depressive sympotms (Mood and Feelings Questionnaire – short version; SMFQ)
smfq_vars = c("fcmdsa00", "fcmdsb00", "fcmdsc00", "fcmdsd00", "fcmdse00", "fcmdsf00", "fcmdsg00", "fcmdsh00", "fcmdsi00", "fcmdsj00", "fcmdsk00", "fcmdsl00", "fcmdsm00")

# Cohort member: 2. self-esteem (Rosenberg)
rosenberg_vars = c("fcsati00", "fcgdql00", "fcdowl00", "fcvalu00", "fcgdsf00")

# Cohort member: 3. happiness
wellbeing_vars = c("fcscwk00", "fcwylk00", "fcfmly00", "fcfrns00", "fcschl00", "fclife00")
names(wellbeing_vars) = c("Happy with school work", "Happy with looks", "Happy with family", "Happy with friends", "Happy with school", "Happy with life")

# Parent: Strengths and Difficulties Questionnaire (SDQ)
sdq_vars = c("fconduct", "fhyper", "fpeer", "fprosoc", "femotion", "febdtot")
names(sdq_vars) = c("Parent-reported conduct problems", "Parent-reported hyperactivity/inattention", "Parent-reported peer problems", "Parent-reported prosocial", "Parent-reported emotional symptoms", "Parent-reported total difficulties")
# remove "Parent-reported" for brevity
names(sdq_vars)= sapply(names(sdq_vars), function(x) gsub('Parent-reported ', '', x), USE.NAMES = FALSE)

OP’s transformation of the SDQ variables is incoherent (see Supplemental Information). We put the variables on the same 1-10 scale below. We also restore inverted measure’s meaning.

More generally, OP are using individual questions that make up established scales (SMFQ, Rosenberg, SDQ). We calculate and use the scales (see Supplemental Information). We invert self-esteem to match the binary outcomes (1=bad).

# Fix incorrectly coded Y variables (SDQ)
data$fprosocr = (data$fprosoc)*(9/10) + 1
data$fconductr = 9 - (data$fconduct - 1)*(9/10) + 1
data$fhyperr = 9 - (data$fhyper - 1)*(9/10) + 1
data$fpeerr = 9 - (data$fpeer - 1)*(9/10) + 1
data$femotionr = 9 - (data$femotion - 1)*(9/10) + 1
data$febdtotr = 40 - (data$febdtot - 1)*(9/40) + 1

add_r = function(s) {return(paste(s, 'r', sep=''))}
sdq_vars = sapply(sdq_vars, add_r)

# Calculate depressive sympotms score (SMFQ)
data$depression = rowSums(data[,smfq_vars] - 1, na.rm = FALSE)
data$depressionr = (data$depression)*(9/26) + 1  # normalise to 1-10

# Calculate self-esteem score (Rosenberg)
data$selfesteem = rowSums(4 - data[,rosenberg_vars], na.rm = FALSE) 
data$selfesteemr = 9 - (data$selfesteem)*(9/15) + 1  # invert and normalise to 1-10

Final selection of variables for linear regression: y_main (main), y_pm (extra parent) and y_cm (extra cohort member).

y_main = c("depressionr", "selfesteemr", "febdtotr", "femotionr")
names(y_main) = c('Depression (adolescent)', 'Self-esteem (adolescent)', 'Total difficulties (parent)', 'Emotional problems (parent)')
y_pm = sdq_vars[1:4]
y_cm = sapply(wellbeing_vars, add_r)  # wellbeing on scale from 1-10 (generated by OP)

2.1.5 Binary outcome variables

Outcome variables are non-binary, so we cannot run the logistical regressions used for the YRBS data. To make results more comparable, we use established cut-offs (see Supplementary Information for sources) to create binary variables and the logistical regression.

data$depressed = data$depression >= 12  # SMFQ
data$selfesteem_lo = data$selfesteem <= 7  # Rosenberg
# SDQ
data$febdtot_hi = 41 - data$febdtot >= 14
data$femotion_hi = 11 - data$femotion >= 4
data$fconduct_hi = 11 - data$fconduct >= 3
data$fhyper_hi = 11 - data$fhyper >= 6
data$fpeer_hi = 11 - data$fpeer >= 3
data$fprosoc_lo = data$fprosoc <= 5

yvars = c('depressed', 'selfesteem_lo', 'febdtot_hi', 'femotion_hi', 'fconduct_hi', 'fhyper_hi', 'fpeer_hi', 'fprosoc_lo')
names(yvars) = c('Depressed (adolescent)', 'Low self-esteem (adolescent)', 'High total difficulties (parent)', 'High emotional problems (parent)', 'High conduct problems (parent)', 'High hyperactivity/inattention (parent)', 'High peer problems (parent)', 'Low pro-sociality (parent)')

y_cont = c('depressionr', 'selfesteemr', 'febdtotr', 'femotionr', 'fconductr', 'fhyperr', 'fpeerr', 'fprosocr')
names(y_cont) = c('Depression (adolescent)', 'Self-esteem (adolescent)', 'Total difficulties (parent)', 'Emotional problems (parent)', 'Conduct problems (parent)', 'Hyperactivity/inattention (parent)', 'Peer problems (parent)', 'Pro-sociality (parent)')

There exists substantial disagreement between parents and children about emotional problems!

cor(na.omit(data[yvars]))
##                depressed selfesteem_lo febdtot_hi femotion_hi fconduct_hi
## depressed     1.00000000    0.48952110  0.1523385   0.1516740  0.11507653
## selfesteem_lo 0.48952110    1.00000000  0.1242103   0.1487095  0.08465079
## febdtot_hi    0.15233852    0.12421034  1.0000000   0.5501526  0.53148043
## femotion_hi   0.15167398    0.14870952  0.5501526   1.0000000  0.26454816
## fconduct_hi   0.11507653    0.08465079  0.5314804   0.2645482  1.00000000
## fhyper_hi     0.05494446    0.02561453  0.5393618   0.2351000  0.36855180
## fpeer_hi      0.12596870    0.09743361  0.4804617   0.3554119  0.23750978
## fprosoc_lo    0.04233625    0.03671423  0.2307906   0.1046074  0.24440139
##                fhyper_hi   fpeer_hi fprosoc_lo
## depressed     0.05494446 0.12596870 0.04233625
## selfesteem_lo 0.02561453 0.09743361 0.03671423
## febdtot_hi    0.53936176 0.48046170 0.23079059
## femotion_hi   0.23510004 0.35541192 0.10460741
## fconduct_hi   0.36855180 0.23750978 0.24440139
## fhyper_hi     1.00000000 0.21080031 0.17866241
## fpeer_hi      0.21080031 1.00000000 0.17666755
## fprosoc_lo    0.17866241 0.17666755 1.00000000

2.1.6 Control variables

Control variables used in MCS study: mother’s ethnicity, educational motivation (mean created by OP), employment, psychological distress (K6 Kessler scale), household income, presence of biological father, number of siblings, closeness to parents (mean created by OP), time spent with primary caretaker, long-term illnesses, adolescent’s own negative attitudes towards school, primary caretaker’s word activity score.

We add: sex, age, BMI (used in YRBS).

In PC’s education, OP do not convert the values correctly. Values 1-5 are NVQ levels, but 95 is “Overseas qualification” and 96 is “None of these”. Employment is the NS-SEC 5 category (1=“Manager” through 5=“Routine”), which means OP exclude all unemployed parents. Instead, we create a variable “employed” that is 1 if the respondend is employed or self-employed and 0 otherwise. Value counts are shown in the Supplemental Information.

data$fcbmin6r= cut(data[,'fcbmin6'], breaks=c(0,20,25,30,Inf)) #discretize body mass index
levels(data$fcbmin6r)= c('underw','normal','overw','obese')

# correct PC’s education
#data[(data$fdacaq00 %in% c(95, 96)), 'fdacaq00'] = NA

# correct longstanding illness (1 = yes)
data$fpclsi00r = ifelse(data$fpclsi00 == 2, 0, data$fpclsi00)

# correct amount of time
data$fpchti00r = 5 - data$fpchti00

# create PC employment dummy
data$employed = ifelse(as.numeric(data$fdact00) %in% c(1, 2), 1, 0)

cvars = c(
  "fccsex00r", "fccage00", "fcbmin6", "edumot", 
  "fd06e00", "clpar", "fcpaab00", 
  "fpwrdscm", "employed", #"fdacaq00", "fd05s00", 
  "fpclsi00r", "fpchti00r", "fdkessl", "fdtots00", "foede000"
)
# long names
names(cvars) = c(
  "Male", "Age", "BMI", "Educational motivation",
  "Mother’s ethnicity", "Closeness to parents", "Presence of natural father", 
  "PC's word activity score", "PC employed", #"PC’s education", "PC’s employment", 
  "Longstanding illness", "Time spent with PC", "PC’s psychological distress", "Number of siblings", "Household income"
)
# short names
names(cvars) = c(
  "Male", "Age", "BMI", "Motivation",
  "Ethnicity", "Closeness", "Father", 
  "Score", "Employed",
  "Illness", "Time", "Distress", "Siblings", "Income"
)

2.2 EXPLORATORY DATA ANALYSIS

2.2.1 Summary statistics

Outcomes

y_all = c(y_main, y_pm, y_cm)
y= data[, y_all]
names(y) = names(y_all)
stargazer(y, type='text')
## 
## ==================================================================================
## Statistic                     N     Mean  St. Dev.  Min   Pctl(25) Pctl(75)  Max  
## ----------------------------------------------------------------------------------
## Depression (adolescent)     11,200 2.909   2.025   1.000   1.346    3.769   10.000
## Self-esteem (adolescent)    11,165 3.656   1.734   1.000   2.200    4.600   10.000
## Total difficulties (parent) 11,471 33.843  1.347   32.000  32.900   34.475  40.550
## Emotional problems (parent) 11,486 2.841   1.925   1.000   1.000    3.700   10.000
## conduct problems            11,488 2.275   1.466   1.000   1.000    2.800   10.000
## hyperactivity/inattention   11,481 3.692   2.163   1.000   1.900    4.600   10.000
## peer problems               11,491 2.569   1.637   1.000   1.000    3.700   10.000
## prosocial                   11,489 8.481   1.665   1.000   7.300    10.000  10.000
## Happy with school work      11,328 7.417   2.080   1.000   5.500    8.500   10.000
## Happy with looks            11,305 6.703   2.363   1.000   5.500    8.500   10.000
## Happy with family           11,306 8.482   2.066   1.000   8.500    10.000  10.000
## Happy with friends          11,317 8.401   1.952   1.000   8.500    10.000  10.000
## Happy with school           11,311 7.679   2.290   1.000   7.000    10.000  10.000
## Happy with life             11,301 7.825   2.147   1.000   7.000    10.000  10.000
## ----------------------------------------------------------------------------------

Controls

controls = data[, cvars]
names(controls) = names(cvars)
stargazer(controls, type='text')
## 
## =====================================================================
## Statistic    N     Mean   St. Dev.  Min   Pctl(25) Pctl(75)    Max   
## ---------------------------------------------------------------------
## Male       11,884  0.501   0.500     0       0        1         1    
## Age        11,884 13.772   0.450     13      14       14       15    
## BMI        11,110 21.451   4.145   7.350   18.560   23.440   46.490  
## Motivation 11,479  3.249   0.496   1.333   3.000    3.667     4.333  
## Ethnicity  11,148  0.836   0.371   0.000   1.000    1.000     1.000  
## Closeness  10,377  3.219   0.649   1.000   2.750    3.750     4.500  
## Father     10,981  1.278   0.448   1.000   1.000    2.000     2.000  
## Score      10,162 11.003   4.376   0.000   8.000    14.000   20.000  
## Employed   11,884  0.684   0.465     0       0        1         1    
## Illness    10,611  0.167   0.373   0.000   0.000    0.000     1.000  
## Time       11,140  1.902   0.882   0.000   1.000    3.000     4.000  
## Distress   10,517  4.337   4.188   0.000   1.000    6.000    24.000  
## Siblings   11,884  2.566   1.151     1       2        3        11    
## Income     11,872 409.718 177.619  80.020 260.802  537.592  1,153.520
## ---------------------------------------------------------------------

2.2.2 Histograms

2.2.2.1 Outcome variables

for (i in 1:length(y_all)){
  cat('\n    \n')
  cat("##### ", names(y_all)[i], '\n')
  hist(x=data[, y_all[[i]]], breaks=10, main=names(y_all)[i], xlim=c(0,10), xlab=NULL)
}
2.2.2.1.1 Depression (adolescent)

2.2.2.1.2 Self-esteem (adolescent)

2.2.2.1.3 Total difficulties (parent)

2.2.2.1.4 Emotional problems (parent)

2.2.2.1.5 conduct problems

2.2.2.1.6 hyperactivity/inattention

2.2.2.1.7 peer problems

2.2.2.1.8 prosocial

2.2.2.1.9 Happy with school work

2.2.2.1.10 Happy with looks

2.2.2.1.11 Happy with family

2.2.2.1.12 Happy with friends

2.2.2.1.13 Happy with school

2.2.2.1.14 Happy with life

2.2.2.2 Treatment variables

for (i in 1:length(x)){
  hist(x=x[[i]], breaks=10, main=names(x)[i], xlim=c(0,1), xlab=NULL)
}

2.2.2.3 Control variables

for (i in 1:length(cvars)){
  cat('\n    \n')
  cat("##### ", names(cvars)[i], '\n')
  hist(x=data[, cvars[[i]]], main=names(cvars)[i], xlab=NULL)
}
2.2.2.3.1 Male

2.2.2.3.2 Age

2.2.2.3.3 BMI

2.2.2.3.4 Motivation

2.2.2.3.5 Ethnicity

2.2.2.3.6 Closeness

2.2.2.3.7 Father

2.2.2.3.8 Score

2.2.2.3.9 Employed

2.2.2.3.10 Illness

2.2.2.3.11 Time

2.2.2.3.12 Distress

2.2.2.3.13 Siblings

2.2.2.3.14 Income

2.2.3 Correlations and missing observations

Outcome variables

y= data[,y_all]; names(y)= names(y_all)
data.frame(round(cor(y,use='pairwise.complete.obs'),3))
Depression..adolescent. Self.esteem..adolescent. Total.difficulties..parent. Emotional.problems..parent. conduct.problems hyperactivity.inattention peer.problems prosocial Happy.with.school.work Happy.with.looks Happy.with.family Happy.with.friends Happy.with.school Happy.with.life
Depression (adolescent) 1.000 0.596 0.232 0.268 0.161 0.095 0.168 -0.065 -0.389 -0.531 -0.414 -0.357 -0.365 -0.607
Self-esteem (adolescent) 0.596 1.000 0.186 0.229 0.124 0.076 0.120 -0.059 -0.396 -0.622 -0.372 -0.338 -0.363 -0.589
Total difficulties (parent) 0.232 0.186 1.000 0.751 0.736 0.783 0.718 -0.438 -0.254 -0.125 -0.171 -0.168 -0.239 -0.212
Emotional problems (parent) 0.268 0.229 0.751 1.000 0.374 0.355 0.494 -0.194 -0.183 -0.170 -0.131 -0.150 -0.177 -0.215
conduct problems 0.161 0.124 0.736 0.374 1.000 0.550 0.364 -0.464 -0.206 -0.092 -0.173 -0.098 -0.189 -0.172
hyperactivity/inattention 0.095 0.076 0.783 0.355 0.550 1.000 0.347 -0.374 -0.222 -0.032 -0.106 -0.086 -0.176 -0.101
peer problems 0.168 0.120 0.718 0.494 0.364 0.347 1.000 -0.305 -0.136 -0.077 -0.108 -0.168 -0.169 -0.151
prosocial -0.065 -0.059 -0.438 -0.194 -0.464 -0.374 -0.305 1.000 0.151 0.038 0.139 0.086 0.135 0.102
Happy with school work -0.389 -0.396 -0.254 -0.183 -0.206 -0.222 -0.136 0.151 1.000 0.453 0.479 0.432 0.551 0.539
Happy with looks -0.531 -0.622 -0.125 -0.170 -0.092 -0.032 -0.077 0.038 0.453 1.000 0.424 0.401 0.404 0.623
Happy with family -0.414 -0.372 -0.171 -0.131 -0.173 -0.106 -0.108 0.139 0.479 0.424 1.000 0.596 0.472 0.655
Happy with friends -0.357 -0.338 -0.168 -0.150 -0.098 -0.086 -0.168 0.086 0.432 0.401 0.596 1.000 0.503 0.583
Happy with school -0.365 -0.363 -0.239 -0.177 -0.189 -0.176 -0.169 0.135 0.551 0.404 0.472 0.503 1.000 0.552
Happy with life -0.607 -0.589 -0.212 -0.215 -0.172 -0.101 -0.151 0.102 0.539 0.623 0.655 0.583 0.552 1.000
colSums(is.na(y))
##     Depression (adolescent)    Self-esteem (adolescent) 
##                         684                         719 
## Total difficulties (parent) Emotional problems (parent) 
##                         413                         398 
##            conduct problems   hyperactivity/inattention 
##                         396                         403 
##               peer problems                   prosocial 
##                         393                         395 
##      Happy with school work            Happy with looks 
##                         556                         579 
##           Happy with family          Happy with friends 
##                         578                         567 
##           Happy with school             Happy with life 
##                         573                         583

Treatment

Internet and social media usage are highly correlated.

xnum= apply(x,2,as.numeric)
round(cor(xnum,use='pairwise.complete.obs'),3)
##                     TV Electronic games Social media Other internet
## TV               1.000            0.195        0.303          0.013
## Electronic games 0.195            1.000        0.007          0.222
## Social media     0.303            0.007        1.000         -0.633
## Other internet   0.013            0.222       -0.633          1.000
## Own computer     0.033            0.040        0.059          0.036
##                  Own computer
## TV                      0.033
## Electronic games        0.040
## Social media            0.059
## Other internet          0.036
## Own computer            1.000

Control variables

datanum= sapply(c(cvars), function(z) as.numeric(data[,z]))
colnames(datanum)= names(cvars)
round(cor(datanum, use='pairwise.complete.obs'),3)
##              Male    Age    BMI Motivation Ethnicity Closeness Father  Score
## Male        1.000 -0.004 -0.126      0.048     0.005     0.100 -0.015 -0.002
## Age        -0.004  1.000  0.051     -0.027     0.017    -0.021 -0.010 -0.010
## BMI        -0.126  0.051  1.000     -0.046    -0.012    -0.034  0.062 -0.102
## Motivation  0.048 -0.027 -0.046      1.000    -0.093     0.385 -0.122  0.030
## Ethnicity   0.005  0.017 -0.012     -0.093     1.000    -0.096  0.074  0.339
## Closeness   0.100 -0.021 -0.034      0.385    -0.096     1.000 -0.077 -0.043
## Father     -0.015 -0.010  0.062     -0.122     0.074    -0.077  1.000 -0.145
## Score      -0.002 -0.010 -0.102      0.030     0.339    -0.043 -0.145  1.000
## Employed   -0.011  0.000 -0.060      0.036     0.241    -0.038 -0.070  0.271
## Illness     0.028  0.006  0.035     -0.087     0.067    -0.039  0.053  0.006
## Time        0.004 -0.022  0.021      0.056    -0.185     0.084 -0.063 -0.146
## Distress   -0.009  0.029  0.086     -0.131    -0.043    -0.098  0.144 -0.142
## Siblings    0.003 -0.014 -0.028     -0.007    -0.269     0.030 -0.043 -0.196
## Income      0.007  0.013 -0.121      0.115     0.292    -0.015 -0.369  0.501
##            Employed Illness   Time Distress Siblings Income
## Male         -0.011   0.028  0.004   -0.009    0.003  0.007
## Age           0.000   0.006 -0.022    0.029   -0.014  0.013
## BMI          -0.060   0.035  0.021    0.086   -0.028 -0.121
## Motivation    0.036  -0.087  0.056   -0.131   -0.007  0.115
## Ethnicity     0.241   0.067 -0.185   -0.043   -0.269  0.292
## Closeness    -0.038  -0.039  0.084   -0.098    0.030 -0.015
## Father       -0.070   0.053 -0.063    0.144   -0.043 -0.369
## Score         0.271   0.006 -0.146   -0.142   -0.196  0.501
## Employed      1.000  -0.092 -0.239   -0.245   -0.257  0.480
## Illness      -0.092   1.000 -0.012    0.123   -0.012 -0.053
## Time         -0.239  -0.012  1.000   -0.042    0.052 -0.122
## Distress     -0.245   0.123 -0.042    1.000    0.057 -0.248
## Siblings     -0.257  -0.012  0.052    0.057    1.000 -0.379
## Income        0.480  -0.053 -0.122   -0.248   -0.379  1.000

2.3 LINEARITY ANALYSIS

2.3.1 Preparation

Format treatment and control variables as factors.

nn= names(x)
xf= x
for (i in 1:length(nn)) xf[,nn[i]]= factor(xf[,nn[i]])
nn= cvars
dataf= data
for (i in 1:length(nn)) dataf[,nn[i]]= factor(dataf[,nn[i]])

2.3.2 Analysis

Linear regression with treatment variables as factors. Control variables are all numerical (e.g. test score) or have been converted in non-obvious ways (e.g. education).

Interesting non-linearity in social media use: same association for first 5 levels (first 3 for prosociality and total difficulties), then sharp decrease in levels 6-8; has positive association with emotional symptoms. Social media use has association with peer problems and prosociality.

y= data[,y_all]; names(y)= names(y_all)

idys= c(1:dim(y)[2]); idx= 1:dim(x)[2]
variables = names(x)[idx]  # which to show

for (idy in idys) {
  cat('\n    \n')
  cat("#### ", 'Outcome: ', names(y)[idy], '\n')
  
  datareg= na.omit(data.frame(y[,idy], xf[,idx], data[,c(cvars)]))
  names(datareg)[1]= 'y'
  names(datareg)[2:(1+length(idx))]= names(x)[idx]
  names(datareg)[-(1:(1+length(idx)))]= names(cvars)
  fit1= glm(y ~ ., data=datareg)
  bmle= getci(fit1)
  cat.asis(summary(fit1))
  
  for (v in variables) {
    sel= grep(v,rownames(bmle))
    plot(bmle[sel,1],ylim=range(bmle[sel,]), xaxt='n')
    segments(x0=1:length(sel),y0=bmle[sel,2],y1=bmle[sel,3])
    axis(side=1, at=1:length(sel), labels=rownames(bmle)[sel])
    title(v)
  }
}

2.3.2.1 Outcome: Depression (adolescent)

Call:
glm(formula = y ~ ., data = datareg)

Deviance Residuals: 
    Min       1Q   Median       3Q      Max  
-4.9091  -1.0562  -0.2789   0.7509   8.0470  

Coefficients:
                                      Estimate Std. Error t value Pr(>|t|)    
(Intercept)                          8.5459482  0.6258303  13.655  < 2e-16 ***
TV0.142857142857143                  0.0029370  0.2017935   0.015 0.988388    
TV0.285714285714286                 -0.1497039  0.1854178  -0.807 0.419467    
TV0.428571428571429                 -0.1534307  0.1800454  -0.852 0.394140    
TV0.571428571428571                 -0.0453996  0.1796640  -0.253 0.800513    
TV0.714285714285714                 -0.1129024  0.1801381  -0.627 0.530837    
TV0.857142857142858                 -0.0337554  0.1847671  -0.183 0.855044    
TV1                                 -0.0271660  0.1884199  -0.144 0.885363    
`Electronic games`0.142857142857143 -0.0890129  0.0634440  -1.403 0.160650    
`Electronic games`0.285714285714286 -0.0335012  0.0680275  -0.492 0.622403    
`Electronic games`0.428571428571429  0.0639981  0.0648899   0.986 0.324036    
`Electronic games`0.571428571428571  0.0272601  0.0689286   0.395 0.692497    
`Electronic games`0.714285714285714  0.0638420  0.0713160   0.895 0.370707    
`Electronic games`0.857142857142858 -0.0203577  0.0885736  -0.230 0.818222    
`Electronic games`1                  0.0288319  0.0918769   0.314 0.753673    
`Social media`0.142857142857143     -0.0419169  0.1063707  -0.394 0.693543    
`Social media`0.285714285714286     -0.0150144  0.1013908  -0.148 0.882280    
`Social media`0.428571428571429     -0.0063011  0.1052252  -0.060 0.952251    
`Social media`0.571428571428571     -0.0734254  0.1079458  -0.680 0.496393    
`Social media`0.714285714285714      0.1498503  0.1087767   1.378 0.168365    
`Social media`0.857142857142858      0.3968374  0.1202603   3.300 0.000972 ***
`Social media`1                      0.3139240  0.1257608   2.496 0.012572 *  
`Other internet`0.142857142857142    0.0566653  0.0717071   0.790 0.429414    
`Other internet`0.142857142857143    0.2432659  0.0640858   3.796 0.000148 ***
`Other internet`0.285714285714285    0.1329601  0.1082226   1.229 0.219264    
`Other internet`0.285714285714286    0.1733267  0.0754282   2.298 0.021592 *  
`Other internet`0.285714285714287    0.4222437  0.1244090   3.394 0.000692 ***
`Other internet`0.428571428571428    0.4161946  0.1447655   2.875 0.004051 ** 
`Other internet`0.428571428571429    0.3011183  0.0838186   3.592 0.000329 ***
`Other internet`0.571428571428571    0.1940705  0.1040396   1.865 0.062167 .  
`Other internet`0.571428571428572    0.6874894  0.1750784   3.927 8.68e-05 ***
`Other internet`0.714285714285714    0.1200670  0.2047206   0.586 0.557561    
`Other internet`0.714285714285715    0.3040802  0.1478379   2.057 0.039732 *  
`Other internet`0.857142857142857    0.3330081  0.2041910   1.631 0.102957    
`Other internet`0.857142857142858    0.5103778  0.2431113   2.099 0.035815 *  
`Other internet`1                   -0.0698546  0.2410289  -0.290 0.771962    
`Own computer`1                     -0.0330092  0.0511429  -0.645 0.518666    
Male                                -0.8374233  0.0447019 -18.734  < 2e-16 ***
Age                                  0.0479825  0.0401317   1.196 0.231877    
BMI                                  0.0354735  0.0045651   7.771 8.74e-15 ***
Motivation                          -1.4785574  0.0422140 -35.025  < 2e-16 ***
Ethnicity                           -0.1331018  0.0600043  -2.218 0.026568 *  
Closeness                           -0.6275572  0.0307371 -20.417  < 2e-16 ***
Father                              -0.0040056  0.0467143  -0.086 0.931670    
Score                                0.0171913  0.0049778   3.454 0.000556 ***
Employed                            -0.0438840  0.0495193  -0.886 0.375536    
Illness                              0.3942903  0.0505720   7.797 7.13e-15 ***
Time                                -0.0241410  0.0214738  -1.124 0.260958    
Distress                             0.0161882  0.0047304   3.422 0.000624 ***
Siblings                            -0.0417453  0.0194204  -2.150 0.031618 *  
Income                               0.0001006  0.0001483   0.679 0.497472    
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

(Dispersion parameter for gaussian family taken to be 2.661311)

    Null deviance: 33174  on 8350  degrees of freedom
Residual deviance: 22089  on 8300  degrees of freedom
AIC: 31926

Number of Fisher Scoring iterations: 2

2.3.2.2 Outcome: Self-esteem (adolescent)

Call:
glm(formula = y ~ ., data = datareg)

Deviance Residuals: 
    Min       1Q   Median       3Q      Max  
-5.2993  -0.9487   0.0987   0.9023   7.2395  

Coefficients:
                                      Estimate Std. Error t value Pr(>|t|)    
(Intercept)                          8.9639896  0.5537726  16.187  < 2e-16 ***
TV0.142857142857143                 -0.4207388  0.1785821  -2.356  0.01850 *  
TV0.285714285714286                 -0.3436622  0.1645247  -2.089  0.03675 *  
TV0.428571428571429                 -0.3666049  0.1598607  -2.293  0.02186 *  
TV0.571428571428571                 -0.2766597  0.1595145  -1.734  0.08289 .  
TV0.714285714285714                 -0.3197289  0.1599365  -1.999  0.04563 *  
TV0.857142857142858                 -0.3159525  0.1640624  -1.926  0.05416 .  
TV1                                 -0.3038783  0.1673161  -1.816  0.06938 .  
`Electronic games`0.142857142857143 -0.0338064  0.0562078  -0.601  0.54755    
`Electronic games`0.285714285714286 -0.0298603  0.0601908  -0.496  0.61984    
`Electronic games`0.428571428571429  0.0559122  0.0574415   0.973  0.33040    
`Electronic games`0.571428571428571  0.0329046  0.0609663   0.540  0.58941    
`Electronic games`0.714285714285714  0.0734639  0.0631708   1.163  0.24489    
`Electronic games`0.857142857142858  0.0448446  0.0786980   0.570  0.56881    
`Electronic games`1                 -0.0282845  0.0810763  -0.349  0.72720    
`Social media`0.142857142857143      0.1316573  0.0935441   1.407  0.15934    
`Social media`0.285714285714286      0.1607061  0.0892172   1.801  0.07169 .  
`Social media`0.428571428571429      0.1943355  0.0926593   2.097  0.03600 *  
`Social media`0.571428571428571      0.0746254  0.0949716   0.786  0.43203    
`Social media`0.714285714285714      0.1219046  0.0957534   1.273  0.20302    
`Social media`0.857142857142858      0.3031020  0.1060162   2.859  0.00426 ** 
`Social media`1                      0.0432859  0.1107398   0.391  0.69590    
`Other internet`0.142857142857142    0.0824789  0.0635157   1.299  0.19413    
`Other internet`0.142857142857143    0.2249238  0.0568288   3.958 7.62e-05 ***
`Other internet`0.285714285714285    0.0485055  0.0956208   0.507  0.61198    
`Other internet`0.285714285714286    0.0683258  0.0666829   1.025  0.30556    
`Other internet`0.285714285714287    0.3229551  0.1099704   2.937  0.00333 ** 
`Other internet`0.428571428571428    0.3407450  0.1281321   2.659  0.00784 ** 
`Other internet`0.428571428571429    0.2977476  0.0741670   4.015 6.01e-05 ***
`Other internet`0.571428571428571    0.2844245  0.0917749   3.099  0.00195 ** 
`Other internet`0.571428571428572    0.2204589  0.1552561   1.420  0.15565    
`Other internet`0.714285714285714    0.4356436  0.1805056   2.413  0.01582 *  
`Other internet`0.714285714285715    0.2350840  0.1314893   1.788  0.07384 .  
`Other internet`0.857142857142857    0.2022209  0.1810812   1.117  0.26414    
`Other internet`0.857142857142858    0.4422139  0.2144816   2.062  0.03926 *  
`Other internet`1                    0.0114686  0.2140824   0.054  0.95728    
`Own computer`1                     -0.0118079  0.0452213  -0.261  0.79401    
Male                                -0.8209860  0.0395178 -20.775  < 2e-16 ***
Age                                 -0.0207259  0.0354998  -0.584  0.55935    
BMI                                  0.0344110  0.0040319   8.535  < 2e-16 ***
Motivation                          -1.1744985  0.0373350 -31.458  < 2e-16 ***
Ethnicity                            0.1419456  0.0529694   2.680  0.00738 ** 
Closeness                           -0.4727448  0.0272299 -17.361  < 2e-16 ***
Father                               0.0337916  0.0413152   0.818  0.41344    
Score                                0.0001534  0.0043991   0.035  0.97219    
Employed                            -0.0040532  0.0439043  -0.092  0.92645    
Illness                              0.2596146  0.0448115   5.793 7.15e-09 ***
Time                                -0.0508958  0.0189873  -2.681  0.00737 ** 
Distress                             0.0059108  0.0041967   1.408  0.15904    
Siblings                            -0.0132085  0.0172337  -0.766  0.44344    
Income                              -0.0001754  0.0001310  -1.338  0.18081    
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

(Dispersion parameter for gaussian family taken to be 2.074693)

    Null deviance: 24087  on 8310  degrees of freedom
Residual deviance: 17137  on 8260  degrees of freedom
AIC: 29704

Number of Fisher Scoring iterations: 2

2.3.2.3 Outcome: Total difficulties (parent)

Call:
glm(formula = y ~ ., data = datareg)

Deviance Residuals: 
    Min       1Q   Median       3Q      Max  
-3.3031  -0.7257  -0.1614   0.5851   5.7841  

Coefficients:
                                      Estimate Std. Error t value Pr(>|t|)    
(Intercept)                          3.711e+01  4.156e-01  89.300  < 2e-16 ***
TV0.142857142857143                  5.032e-02  1.334e-01   0.377 0.706014    
TV0.285714285714286                  2.646e-02  1.229e-01   0.215 0.829567    
TV0.428571428571429                 -4.080e-02  1.193e-01  -0.342 0.732408    
TV0.571428571428571                 -2.061e-02  1.191e-01  -0.173 0.862575    
TV0.714285714285714                 -8.008e-02  1.194e-01  -0.671 0.502348    
TV0.857142857142858                 -3.388e-02  1.225e-01  -0.277 0.782103    
TV1                                  6.135e-02  1.248e-01   0.492 0.623029    
`Electronic games`0.142857142857143 -2.481e-02  4.240e-02  -0.585 0.558543    
`Electronic games`0.285714285714286  2.560e-02  4.544e-02   0.563 0.573199    
`Electronic games`0.428571428571429  4.590e-02  4.334e-02   1.059 0.289597    
`Electronic games`0.571428571428571  4.622e-02  4.592e-02   1.007 0.314175    
`Electronic games`0.714285714285714  1.641e-01  4.756e-02   3.451 0.000561 ***
`Electronic games`0.857142857142858  1.981e-01  5.919e-02   3.347 0.000821 ***
`Electronic games`1                  2.187e-01  6.098e-02   3.587 0.000337 ***
`Social media`0.142857142857143     -4.057e-01  7.058e-02  -5.748 9.33e-09 ***
`Social media`0.285714285714286     -3.900e-01  6.746e-02  -5.781 7.71e-09 ***
`Social media`0.428571428571429     -5.012e-01  6.991e-02  -7.169 8.22e-13 ***
`Social media`0.571428571428571     -5.386e-01  7.176e-02  -7.507 6.70e-14 ***
`Social media`0.714285714285714     -5.315e-01  7.225e-02  -7.356 2.07e-13 ***
`Social media`0.857142857142858     -4.880e-01  8.002e-02  -6.099 1.11e-09 ***
`Social media`1                     -4.830e-01  8.347e-02  -5.786 7.46e-09 ***
`Other internet`0.142857142857142   -8.829e-02  4.782e-02  -1.846 0.064922 .  
`Other internet`0.142857142857143   -3.894e-02  4.279e-02  -0.910 0.362901    
`Other internet`0.285714285714285   -5.272e-02  7.242e-02  -0.728 0.466659    
`Other internet`0.285714285714286    4.053e-02  5.026e-02   0.806 0.420009    
`Other internet`0.285714285714287    1.062e-01  8.346e-02   1.272 0.203327    
`Other internet`0.428571428571428   -6.563e-02  9.635e-02  -0.681 0.495765    
`Other internet`0.428571428571429   -2.600e-02  5.594e-02  -0.465 0.642033    
`Other internet`0.571428571428571    6.091e-02  6.910e-02   0.881 0.378090    
`Other internet`0.571428571428572   -1.666e-01  1.165e-01  -1.429 0.152947    
`Other internet`0.714285714285714   -2.442e-01  1.344e-01  -1.817 0.069292 .  
`Other internet`0.714285714285715   -1.566e-01  9.848e-02  -1.591 0.111733    
`Other internet`0.857142857142857   -3.630e-02  1.359e-01  -0.267 0.789435    
`Other internet`0.857142857142858    8.146e-02  1.623e-01   0.502 0.615738    
`Other internet`1                    1.317e-02  1.596e-01   0.083 0.934236    
`Own computer`1                     -2.898e-02  3.409e-02  -0.850 0.395245    
Male                                 6.433e-02  2.981e-02   2.158 0.030937 *  
Age                                 -6.021e-02  2.669e-02  -2.256 0.024115 *  
BMI                                  2.081e-02  3.034e-03   6.859 7.44e-12 ***
Motivation                          -4.112e-01  2.805e-02 -14.661  < 2e-16 ***
Ethnicity                            4.628e-02  4.000e-02   1.157 0.247278    
Closeness                           -2.746e-01  2.046e-02 -13.424  < 2e-16 ***
Father                               8.696e-02  3.108e-02   2.798 0.005156 ** 
Score                               -3.412e-02  3.320e-03 -10.280  < 2e-16 ***
Employed                            -1.108e-01  3.299e-02  -3.360 0.000784 ***
Illness                              6.014e-01  3.364e-02  17.881  < 2e-16 ***
Time                                -4.723e-02  1.430e-02  -3.303 0.000959 ***
Distress                             7.425e-02  3.146e-03  23.603  < 2e-16 ***
Siblings                            -3.147e-02  1.295e-02  -2.430 0.015136 *  
Income                              -6.826e-04  9.927e-05  -6.876 6.59e-12 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

(Dispersion parameter for gaussian family taken to be 1.167304)

    Null deviance: 13292.7  on 8237  degrees of freedom
Residual deviance:  9556.7  on 8187  degrees of freedom
AIC: 24706

Number of Fisher Scoring iterations: 2

2.3.2.4 Outcome: Emotional problems (parent)

Call:
glm(formula = y ~ ., data = datareg)

Deviance Residuals: 
    Min       1Q   Median       3Q      Max  
-4.9291  -1.1311  -0.3952   0.8771   7.7409  

Coefficients:
                                      Estimate Std. Error t value Pr(>|t|)    
(Intercept)                          4.4879150  0.6360560   7.056 1.86e-12 ***
TV0.142857142857143                  0.0366279  0.2042138   0.179  0.85766    
TV0.285714285714286                 -0.0003123  0.1881462  -0.002  0.99868    
TV0.428571428571429                 -0.0876117  0.1826771  -0.480  0.63153    
TV0.571428571428571                 -0.0280957  0.1822769  -0.154  0.87751    
TV0.714285714285714                 -0.0694085  0.1827426  -0.380  0.70409    
TV0.857142857142858                 -0.0124972  0.1875108  -0.067  0.94686    
TV1                                  0.0959708  0.1910462   0.502  0.61544    
`Electronic games`0.142857142857143 -0.0060085  0.0649121  -0.093  0.92625    
`Electronic games`0.285714285714286  0.0903322  0.0695645   1.299  0.19414    
`Electronic games`0.428571428571429  0.0554452  0.0663349   0.836  0.40327    
`Electronic games`0.571428571428571  0.1419532  0.0702901   2.020  0.04346 *  
`Electronic games`0.714285714285714  0.2127224  0.0727700   2.923  0.00347 ** 
`Electronic games`0.857142857142858  0.1925554  0.0906050   2.125  0.03360 *  
`Electronic games`1                  0.1568541  0.0933471   1.680  0.09293 .  
`Social media`0.142857142857143     -0.4462681  0.1080444  -4.130 3.66e-05 ***
`Social media`0.285714285714286     -0.4194837  0.1032695  -4.062 4.91e-05 ***
`Social media`0.428571428571429     -0.5017020  0.1070151  -4.688 2.80e-06 ***
`Social media`0.571428571428571     -0.6306029  0.1098266  -5.742 9.70e-09 ***
`Social media`0.714285714285714     -0.6664391  0.1105977  -6.026 1.76e-09 ***
`Social media`0.857142857142858     -0.5099745  0.1224889  -4.163 3.17e-05 ***
`Social media`1                     -0.6530709  0.1277723  -5.111 3.27e-07 ***
`Other internet`0.142857142857142   -0.1353847  0.0732084  -1.849  0.06445 .  
`Other internet`0.142857142857143   -0.0001211  0.0654807  -0.002  0.99852    
`Other internet`0.285714285714285   -0.0867363  0.1108585  -0.782  0.43400    
`Other internet`0.285714285714286    0.1237103  0.0769289   1.608  0.10785    
`Other internet`0.285714285714287    0.1412374  0.1277431   1.106  0.26892    
`Other internet`0.428571428571428    0.0004878  0.1474870   0.003  0.99736    
`Other internet`0.428571428571429   -0.0049284  0.0856263  -0.058  0.95410    
`Other internet`0.571428571428571    0.0546861  0.1057721   0.517  0.60516    
`Other internet`0.571428571428572   -0.0561511  0.1784067  -0.315  0.75297    
`Other internet`0.714285714285714   -0.1862621  0.2057581  -0.905  0.36536    
`Other internet`0.714285714285715   -0.2872531  0.1507473  -1.906  0.05675 .  
`Other internet`0.857142857142857    0.1252132  0.2081007   0.602  0.54739    
`Other internet`0.857142857142858    0.1060773  0.2484457   0.427  0.66942    
`Other internet`1                    0.2775536  0.2443112   1.136  0.25596    
`Own computer`1                      0.0477679  0.0521782   0.915  0.35997    
Male                                -0.6720859  0.0456187 -14.733  < 2e-16 ***
Age                                  0.0300544  0.0408495   0.736  0.46191    
BMI                                  0.0190930  0.0046434   4.112 3.96e-05 ***
Motivation                          -0.4535915  0.0429311 -10.566  < 2e-16 ***
Ethnicity                            0.0625827  0.0612074   1.022  0.30659    
Closeness                           -0.1239642  0.0313115  -3.959 7.59e-05 ***
Father                               0.0743062  0.0475739   1.562  0.11835    
Score                               -0.0306648  0.0050811  -6.035 1.66e-09 ***
Employed                            -0.0804697  0.0505005  -1.593  0.11110    
Illness                              0.9711950  0.0514884  18.862  < 2e-16 ***
Time                                -0.0291789  0.0218868  -1.333  0.18251    
Distress                             0.1102321  0.0048154  22.891  < 2e-16 ***
Siblings                            -0.0421975  0.0198268  -2.128  0.03334 *  
Income                              -0.0004130  0.0001519  -2.718  0.00658 ** 
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

(Dispersion parameter for gaussian family taken to be 2.735395)

    Null deviance: 28171  on 8239  degrees of freedom
Residual deviance: 22400  on 8189  degrees of freedom
AIC: 31729

Number of Fisher Scoring iterations: 2

2.3.2.5 Outcome: conduct problems

Call:
glm(formula = y ~ ., data = datareg)

Deviance Residuals: 
    Min       1Q   Median       3Q      Max  
-3.2732  -0.8268  -0.2462   0.5998   6.6910  

Coefficients:
                                      Estimate Std. Error t value Pr(>|t|)    
(Intercept)                          5.2294672  0.4677859  11.179  < 2e-16 ***
TV0.142857142857143                  0.3022254  0.1501877   2.012  0.04422 *  
TV0.285714285714286                  0.2132399  0.1383644   1.541  0.12332    
TV0.428571428571429                  0.1488525  0.1343471   1.108  0.26791    
TV0.571428571428571                  0.1243768  0.1340527   0.928  0.35353    
TV0.714285714285714                  0.0755832  0.1343972   0.562  0.57387    
TV0.857142857142858                  0.1129553  0.1379073   0.819  0.41277    
TV1                                  0.0743843  0.1405038   0.529  0.59653    
`Electronic games`0.142857142857143 -0.0900151  0.0477291  -1.886  0.05934 .  
`Electronic games`0.285714285714286 -0.1182180  0.0511608  -2.311  0.02087 *  
`Electronic games`0.428571428571429 -0.0776935  0.0487708  -1.593  0.11119    
`Electronic games`0.571428571428571 -0.0640986  0.0516888  -1.240  0.21498    
`Electronic games`0.714285714285714  0.0395430  0.0535360   0.739  0.46016    
`Electronic games`0.857142857142858  0.0329976  0.0666340   0.495  0.62047    
`Electronic games`1                  0.1124051  0.0686513   1.637  0.10160    
`Social media`0.142857142857143     -0.1992967  0.0794605  -2.508  0.01216 *  
`Social media`0.285714285714286     -0.1576514  0.0759344  -2.076  0.03791 *  
`Social media`0.428571428571429     -0.2362279  0.0787034  -3.001  0.00269 ** 
`Social media`0.571428571428571     -0.2235356  0.0807699  -2.768  0.00566 ** 
`Social media`0.714285714285714     -0.2022447  0.0813261  -2.487  0.01291 *  
`Social media`0.857142857142858     -0.1362258  0.0900825  -1.512  0.13051    
`Social media`1                     -0.1008192  0.0939679  -1.073  0.28334    
`Other internet`0.142857142857142   -0.1115220  0.0538403  -2.071  0.03836 *  
`Other internet`0.142857142857143   -0.1007949  0.0481488  -2.093  0.03634 *  
`Other internet`0.285714285714285   -0.0921587  0.0814517  -1.131  0.25790    
`Other internet`0.285714285714286   -0.0282616  0.0565704  -0.500  0.61738    
`Other internet`0.285714285714287    0.0312970  0.0939473   0.333  0.73904    
`Other internet`0.428571428571428   -0.1720070  0.1084664  -1.586  0.11282    
`Other internet`0.428571428571429   -0.1725616  0.0629715  -2.740  0.00615 ** 
`Other internet`0.571428571428571   -0.1061457  0.0777890  -1.365  0.17244    
`Other internet`0.571428571428572   -0.2756309  0.1312002  -2.101  0.03569 *  
`Other internet`0.714285714285714   -0.1934368  0.1513233  -1.278  0.20118    
`Other internet`0.714285714285715   -0.1591636  0.1108622  -1.436  0.15113    
`Other internet`0.857142857142857   -0.3439610  0.1530458  -2.247  0.02464 *  
`Other internet`0.857142857142858   -0.1754726  0.1827177  -0.960  0.33691    
`Other internet`1                   -0.2594551  0.1796766  -1.444  0.14877    
`Own computer`1                     -0.0854845  0.0383617  -2.228  0.02588 *  
Male                                 0.1565901  0.0335488   4.668 3.10e-06 ***
Age                                 -0.0501348  0.0300413  -1.669  0.09518 .  
BMI                                  0.0174058  0.0034147   5.097 3.52e-07 ***
Motivation                          -0.2774700  0.0315698  -8.789  < 2e-16 ***
Ethnicity                            0.1006514  0.0449761   2.238  0.02526 *  
Closeness                           -0.4745192  0.0230288 -20.605  < 2e-16 ***
Father                               0.0717066  0.0349772   2.050  0.04039 *  
Score                               -0.0280501  0.0037349  -7.510 6.52e-14 ***
Employed                            -0.0818203  0.0371304  -2.204  0.02758 *  
Illness                              0.2396976  0.0378648   6.330 2.57e-10 ***
Time                                -0.0253110  0.0160961  -1.572  0.11587    
Distress                             0.0488831  0.0035379  13.817  < 2e-16 ***
Siblings                             0.0431690  0.0145726   2.962  0.00306 ** 
Income                              -0.0006665  0.0001117  -5.966 2.54e-09 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

(Dispersion parameter for gaussian family taken to be 1.479519)

    Null deviance: 14979  on 8242  degrees of freedom
Residual deviance: 12120  on 8192  degrees of freedom
AIC: 26674

Number of Fisher Scoring iterations: 2

2.3.2.6 Outcome: hyperactivity/inattention

Call:
glm(formula = y ~ ., data = datareg)

Deviance Residuals: 
    Min       1Q   Median       3Q      Max  
-5.2723  -1.3635  -0.2479   1.1209   7.6837  

Coefficients:
                                      Estimate Std. Error t value Pr(>|t|)    
(Intercept)                         10.0432764  0.7248252  13.856  < 2e-16 ***
TV0.142857142857143                 -0.1982492  0.2327159  -0.852 0.394298    
TV0.285714285714286                 -0.0979058  0.2143956  -0.457 0.647928    
TV0.428571428571429                 -0.2123395  0.2081729  -1.020 0.307751    
TV0.571428571428571                 -0.2044522  0.2077143  -0.984 0.324999    
TV0.714285714285714                 -0.3099294  0.2082480  -1.488 0.136718    
TV0.857142857142858                 -0.2693279  0.2136820  -1.260 0.207556    
TV1                                 -0.1409150  0.2177110  -0.647 0.517484    
`Electronic games`0.142857142857143 -0.0280048  0.0739563  -0.379 0.704945    
`Electronic games`0.285714285714286  0.0725762  0.0792734   0.916 0.359947    
`Electronic games`0.428571428571429  0.1266491  0.0755844   1.676 0.093855 .  
`Electronic games`0.571428571428571 -0.0062371  0.0800905  -0.078 0.937929    
`Electronic games`0.714285714285714  0.1688939  0.0829234   2.037 0.041708 *  
`Electronic games`0.857142857142858  0.2204151  0.1032487   2.135 0.032807 *  
`Electronic games`1                  0.1594003  0.1063730   1.499 0.134041    
`Social media`0.142857142857143     -0.4278847  0.1231241  -3.475 0.000513 ***
`Social media`0.285714285714286     -0.3090216  0.1176604  -2.626 0.008646 ** 
`Social media`0.428571428571429     -0.4787695  0.1219511  -3.926 8.71e-05 ***
`Social media`0.571428571428571     -0.4339959  0.1251517  -3.468 0.000528 ***
`Social media`0.714285714285714     -0.3538344  0.1260318  -2.808 0.005005 ** 
`Social media`0.857142857142858     -0.4586976  0.1395831  -3.286 0.001020 ** 
`Social media`1                     -0.2714245  0.1456035  -1.864 0.062339 .  
`Other internet`0.142857142857142   -0.0829871  0.0834256  -0.995 0.319891    
`Other internet`0.142857142857143   -0.1092372  0.0745900  -1.465 0.143095    
`Other internet`0.285714285714285   -0.1417080  0.1262096  -1.123 0.261556    
`Other internet`0.285714285714286   -0.0924159  0.0876597  -1.054 0.291796    
`Other internet`0.285714285714287    0.0427301  0.1455709   0.294 0.769121    
`Other internet`0.428571428571428   -0.1792056  0.1680694  -1.066 0.286338    
`Other internet`0.428571428571429   -0.2297183  0.0975748  -2.354 0.018582 *  
`Other internet`0.571428571428571   -0.1062223  0.1205342  -0.881 0.378202    
`Other internet`0.571428571428572   -0.3712183  0.2032950  -1.826 0.067885 .  
`Other internet`0.714285714285714   -0.7306777  0.2344759  -3.116 0.001838 ** 
`Other internet`0.714285714285715   -0.2918438  0.1717812  -1.699 0.089371 .  
`Other internet`0.857142857142857   -0.2309855  0.2371448  -0.974 0.330072    
`Other internet`0.857142857142858    0.2648302  0.2831212   0.935 0.349612    
`Other internet`1                   -0.5563421  0.2784095  -1.998 0.045719 *  
`Own computer`1                     -0.1301652  0.0594587  -2.189 0.028613 *  
Male                                 0.8395225  0.0519807  16.151  < 2e-16 ***
Age                                 -0.1526406  0.0465483  -3.279 0.001045 ** 
BMI                                  0.0068683  0.0052913   1.298 0.194308    
Motivation                          -0.7332327  0.0489120 -14.991  < 2e-16 ***
Ethnicity                            0.0885581  0.0697113   1.270 0.203994    
Closeness                           -0.3233755  0.0356805  -9.063  < 2e-16 ***
Father                               0.0955786  0.0541962   1.764 0.077842 .  
Score                               -0.0521343  0.0057880  -9.007  < 2e-16 ***
Employed                            -0.1420955  0.0575385  -2.470 0.013548 *  
Illness                              0.6306195  0.0586718  10.748  < 2e-16 ***
Time                                -0.0974043  0.0249407  -3.905 9.48e-05 ***
Distress                             0.0818893  0.0054831  14.935  < 2e-16 ***
Siblings                            -0.0661177  0.0225802  -2.928 0.003419 ** 
Income                              -0.0009756  0.0001731  -5.636 1.80e-08 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

(Dispersion parameter for gaussian family taken to be 3.55226)

    Null deviance: 36594  on 8242  degrees of freedom
Residual deviance: 29100  on 8192  degrees of freedom
AIC: 33894

Number of Fisher Scoring iterations: 2

2.3.2.7 Outcome: peer problems

Call:
glm(formula = y ~ ., data = datareg)

Deviance Residuals: 
    Min       1Q   Median       3Q      Max  
-3.7810  -0.9850  -0.3187   0.7298   7.6678  

Coefficients:
                                      Estimate Std. Error t value Pr(>|t|)    
(Intercept)                          4.6853757  0.5558401   8.429  < 2e-16 ***
TV0.142857142857143                  0.0603811  0.1784376   0.338 0.735080    
TV0.285714285714286                 -0.0011086  0.1643904  -0.007 0.994620    
TV0.428571428571429                 -0.0134690  0.1596176  -0.084 0.932754    
TV0.571428571428571                  0.0241567  0.1592675   0.152 0.879448    
TV0.714285714285714                 -0.0159706  0.1596754  -0.100 0.920331    
TV0.857142857142858                  0.0283754  0.1638430   0.173 0.862509    
TV1                                  0.2147029  0.1669324   1.286 0.198421    
`Electronic games`0.142857142857143  0.0211092  0.0567068   0.372 0.709715    
`Electronic games`0.285714285714286  0.0566095  0.0607839   0.931 0.351714    
`Electronic games`0.428571428571429  0.0857430  0.0579526   1.480 0.139035    
`Electronic games`0.571428571428571  0.1172935  0.0613893   1.911 0.056084 .  
`Electronic games`0.714285714285714  0.2306664  0.0635811   3.628 0.000287 ***
`Electronic games`0.857142857142858  0.3450173  0.0791649   4.358 1.33e-05 ***
`Electronic games`1                  0.4439983  0.0815607   5.444 5.37e-08 ***
`Social media`0.142857142857143     -0.5504498  0.0944068  -5.831 5.73e-09 ***
`Social media`0.285714285714286     -0.6708433  0.0902168  -7.436 1.14e-13 ***
`Social media`0.428571428571429     -0.7887053  0.0935055  -8.435  < 2e-16 ***
`Social media`0.571428571428571     -0.8627836  0.0959714  -8.990  < 2e-16 ***
`Social media`0.714285714285714     -0.9003037  0.0966189  -9.318  < 2e-16 ***
`Social media`0.857142857142858     -0.8473614  0.1070220  -7.918 2.74e-15 ***
`Social media`1                     -0.9073853  0.1116377  -8.128 5.00e-16 ***
`Other internet`0.142857142857142   -0.0242444  0.0639676  -0.379 0.704690    
`Other internet`0.142857142857143    0.0494835  0.0571911   0.865 0.386938    
`Other internet`0.285714285714285    0.1139823  0.0967722   1.178 0.238894    
`Other internet`0.285714285714286    0.1555485  0.0672074   2.314 0.020667 *  
`Other internet`0.285714285714287    0.2052525  0.1116308   1.839 0.065999 .  
`Other internet`0.428571428571428    0.0865105  0.1288667   0.671 0.502037    
`Other internet`0.428571428571429    0.3002307  0.0748172   4.013 6.05e-05 ***
`Other internet`0.571428571428571    0.4006631  0.0924198   4.335 1.47e-05 ***
`Other internet`0.571428571428572    0.0344333  0.1558779   0.221 0.825176    
`Other internet`0.714285714285714    0.1325193  0.1797854   0.737 0.461084    
`Other internet`0.714285714285715    0.1092863  0.1317135   0.830 0.406717    
`Other internet`0.857142857142857    0.3058043  0.1818326   1.682 0.092648 .  
`Other internet`0.857142857142858    0.1310428  0.2170851   0.604 0.546095    
`Other internet`1                    0.5909909  0.2134722   2.768 0.005645 ** 
`Own computer`1                      0.0537627  0.0455756   1.180 0.238178    
Male                                -0.0635716  0.0398521  -1.595 0.110709    
Age                                 -0.0686242  0.0356973  -1.922 0.054591 .  
BMI                                  0.0400779  0.0040577   9.877  < 2e-16 ***
Motivation                          -0.1831585  0.0374978  -4.885 1.06e-06 ***
Ethnicity                           -0.0661094  0.0534338  -1.237 0.216041    
Closeness                           -0.1738387  0.0273570  -6.354 2.20e-10 ***
Father                               0.1089620  0.0415453   2.623 0.008739 ** 
Score                               -0.0265889  0.0044377  -5.992 2.17e-09 ***
Employed                            -0.1410287  0.0441125  -3.197 0.001394 ** 
Illness                              0.5638276  0.0449868  12.533  < 2e-16 ***
Time                                -0.0354140  0.0191234  -1.852 0.064081 .  
Distress                             0.0554783  0.0042033  13.199  < 2e-16 ***
Siblings                            -0.0601847  0.0173112  -3.477 0.000510 ***
Income                              -0.0006713  0.0001327  -5.058 4.33e-07 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

(Dispersion parameter for gaussian family taken to be 2.088455)

    Null deviance: 20429  on 8243  degrees of freedom
Residual deviance: 17111  on 8193  degrees of freedom
AIC: 29519

Number of Fisher Scoring iterations: 2

2.3.2.8 Outcome: prosocial

Call:
glm(formula = y ~ ., data = datareg)

Deviance Residuals: 
    Min       1Q   Median       3Q      Max  
-7.7651  -0.7925   0.4071   1.0686   3.1440  

Coefficients:
                                      Estimate Std. Error t value Pr(>|t|)    
(Intercept)                          5.8211847  0.5797367  10.041  < 2e-16 ***
TV0.142857142857143                 -0.0072958  0.1861214  -0.039 0.968733    
TV0.285714285714286                 -0.0636901  0.1714693  -0.371 0.710321    
TV0.428571428571429                 -0.0399919  0.1664909  -0.240 0.810178    
TV0.571428571428571                 -0.0452216  0.1661286  -0.272 0.785469    
TV0.714285714285714                  0.0631078  0.1665517   0.379 0.704766    
TV0.857142857142858                 -0.0049954  0.1708991  -0.029 0.976682    
TV1                                 -0.0428242  0.1741216  -0.246 0.805732    
`Electronic games`0.142857142857143  0.0942978  0.0591624   1.594 0.111001    
`Electronic games`0.285714285714286  0.1401519  0.0634016   2.211 0.027095 *  
`Electronic games`0.428571428571429 -0.0211649  0.0604458  -0.350 0.726238    
`Electronic games`0.571428571428571 -0.0275069  0.0640328  -0.430 0.667516    
`Electronic games`0.714285714285714 -0.1355125  0.0663189  -2.043 0.041050 *  
`Electronic games`0.857142857142858 -0.2812896  0.0825740  -3.407 0.000661 ***
`Electronic games`1                 -0.1884917  0.0850727  -2.216 0.026743 *  
`Social media`0.142857142857143      0.1848017  0.0984846   1.876 0.060629 .  
`Social media`0.285714285714286      0.2814892  0.0941019   2.991 0.002786 ** 
`Social media`0.428571428571429      0.2769735  0.0975395   2.840 0.004528 ** 
`Social media`0.571428571428571      0.2947795  0.1000931   2.945 0.003238 ** 
`Social media`0.714285714285714      0.2353780  0.1007896   2.335 0.019550 *  
`Social media`0.857142857142858      0.1837424  0.1116380   1.646 0.099828 .  
`Social media`1                      0.1586274  0.1164484   1.362 0.173168    
`Other internet`0.142857142857142    0.0216174  0.0667403   0.324 0.746019    
`Other internet`0.142857142857143   -0.0248632  0.0596685  -0.417 0.676917    
`Other internet`0.285714285714285   -0.0513430  0.1009403  -0.509 0.611013    
`Other internet`0.285714285714286    0.0213768  0.0701070   0.305 0.760437    
`Other internet`0.285714285714287   -0.0552827  0.1164274  -0.475 0.634924    
`Other internet`0.428571428571428   -0.0781910  0.1344344  -0.582 0.560832    
`Other internet`0.428571428571429   -0.0959625  0.0780393  -1.230 0.218856    
`Other internet`0.571428571428571   -0.1064798  0.0964051  -1.105 0.269407    
`Other internet`0.571428571428572   -0.1272162  0.1625933  -0.782 0.433990    
`Other internet`0.714285714285714   -0.1789839  0.1875290  -0.954 0.339893    
`Other internet`0.714285714285715   -0.1276222  0.1373927  -0.929 0.352975    
`Other internet`0.857142857142857   -0.1513072  0.1896751  -0.798 0.425057    
`Other internet`0.857142857142858   -0.0718819  0.2264360  -0.317 0.750911    
`Other internet`1                   -0.0488638  0.2226669  -0.219 0.826306    
`Own computer`1                      0.1461016  0.0475384   3.073 0.002124 ** 
Male                                -0.3788588  0.0415660  -9.115  < 2e-16 ***
Age                                  0.0154269  0.0372291   0.414 0.678608    
BMI                                  0.0088736  0.0042323   2.097 0.036055 *  
Motivation                           0.3193935  0.0391168   8.165 3.69e-16 ***
Ethnicity                            0.0038885  0.0557216   0.070 0.944367    
Closeness                            0.4240584  0.0285372  14.860  < 2e-16 ***
Father                              -0.0282694  0.0433363  -0.652 0.514209    
Score                               -0.0012243  0.0046284  -0.265 0.791386    
Employed                             0.0582584  0.0460119   1.266 0.205492    
Illness                             -0.1409099  0.0469244  -3.003 0.002682 ** 
Time                                 0.0728245  0.0199499   3.650 0.000263 ***
Distress                            -0.0279036  0.0043841  -6.365 2.06e-10 ***
Siblings                            -0.0746380  0.0180559  -4.134 3.60e-05 ***
Income                               0.0001230  0.0001384   0.888 0.374381    
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

(Dispersion parameter for gaussian family taken to be 2.272191)

    Null deviance: 20812  on 8242  degrees of freedom
Residual deviance: 18614  on 8192  degrees of freedom
AIC: 30211

Number of Fisher Scoring iterations: 2

2.3.2.9 Outcome: Happy with school work

Call:
glm(formula = y ~ ., data = datareg)

Deviance Residuals: 
    Min       1Q   Median       3Q      Max  
-8.7481  -0.7697   0.2416   1.0712   6.7283  

Coefficients:
                                      Estimate Std. Error t value Pr(>|t|)    
(Intercept)                         -1.8565920  0.6446357  -2.880 0.003986 ** 
TV0.142857142857143                  0.0693192  0.2073287   0.334 0.738128    
TV0.285714285714286                 -0.0863996  0.1909450  -0.452 0.650932    
TV0.428571428571429                  0.0705018  0.1853667   0.380 0.703705    
TV0.571428571428571                  0.0858119  0.1849506   0.464 0.642680    
TV0.714285714285714                  0.0121348  0.1854314   0.065 0.947824    
TV0.857142857142858                  0.0461276  0.1902427   0.242 0.808424    
TV1                                  0.1211532  0.1939822   0.625 0.532278    
`Electronic games`0.142857142857143 -0.0851858  0.0654044  -1.302 0.192799    
`Electronic games`0.285714285714286  0.0157269  0.0702570   0.224 0.822881    
`Electronic games`0.428571428571429 -0.0054869  0.0669471  -0.082 0.934682    
`Electronic games`0.571428571428571  0.0185958  0.0710463   0.262 0.793527    
`Electronic games`0.714285714285714 -0.0672222  0.0736447  -0.913 0.361379    
`Electronic games`0.857142857142858 -0.1375381  0.0915040  -1.503 0.132856    
`Electronic games`1                 -0.0631987  0.0945364  -0.669 0.503825    
`Social media`0.142857142857143     -0.0467137  0.1093790  -0.427 0.669332    
`Social media`0.285714285714286     -0.0612191  0.1042043  -0.587 0.556890    
`Social media`0.428571428571429     -0.0419395  0.1081460  -0.388 0.698170    
`Social media`0.571428571428571      0.0250624  0.1109147   0.226 0.821237    
`Social media`0.714285714285714     -0.0738429  0.1117369  -0.661 0.508718    
`Social media`0.857142857142858     -0.0834468  0.1236720  -0.675 0.499858    
`Social media`1                     -0.1239951  0.1292790  -0.959 0.337522    
`Other internet`0.142857142857142    0.0576051  0.0740154   0.778 0.436423    
`Other internet`0.142857142857143    0.0637077  0.0660638   0.964 0.334906    
`Other internet`0.285714285714285    0.0386472  0.1116452   0.346 0.729231    
`Other internet`0.285714285714286    0.1265857  0.0777572   1.628 0.103571    
`Other internet`0.285714285714287    0.0035878  0.1287076   0.028 0.977762    
`Other internet`0.428571428571428   -0.0711876  0.1497287  -0.475 0.634483    
`Other internet`0.428571428571429    0.0387034  0.0865257   0.447 0.654666    
`Other internet`0.571428571428571   -0.0136498  0.1070257  -0.128 0.898518    
`Other internet`0.571428571428572   -0.2492986  0.1811514  -1.376 0.168800    
`Other internet`0.714285714285714   -0.0044497  0.2095533  -0.021 0.983059    
`Other internet`0.714285714285715    0.2574240  0.1529202   1.683 0.092337 .  
`Other internet`0.857142857142857   -0.1119643  0.2111273  -0.530 0.595907    
`Other internet`0.857142857142858   -0.2831156  0.2512898  -1.127 0.259923    
`Other internet`1                   -0.5429620  0.2474190  -2.195 0.028227 *  
`Own computer`1                      0.0249436  0.0527259   0.473 0.636168    
Male                                -0.0047887  0.0460994  -0.104 0.917269    
Age                                  0.0774680  0.0413902   1.872 0.061290 .  
BMI                                 -0.0078748  0.0046976  -1.676 0.093709 .  
Motivation                           2.0819219  0.0434622  47.902  < 2e-16 ***
Ethnicity                            0.2088956  0.0618754   3.376 0.000739 ***
Closeness                            0.3649935  0.0316785  11.522  < 2e-16 ***
Father                              -0.0645499  0.0481112  -1.342 0.179736    
Score                                0.0073000  0.0051303   1.423 0.154799    
Employed                             0.0308584  0.0510976   0.604 0.545919    
Illness                             -0.2091066  0.0520705  -4.016 5.98e-05 ***
Time                                 0.0237990  0.0221361   1.075 0.282352    
Distress                            -0.0086099  0.0048755  -1.766 0.077443 .  
Siblings                             0.0234029  0.0200105   1.170 0.242223    
Income                               0.0004735  0.0001529   3.097 0.001964 ** 
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

(Dispersion parameter for gaussian family taken to be 2.852465)

    Null deviance: 35326  on 8410  degrees of freedom
Residual deviance: 23847  on 8360  degrees of freedom
AIC: 32738

Number of Fisher Scoring iterations: 2

2.3.2.10 Outcome: Happy with looks

Call:
glm(formula = y ~ ., data = datareg)

Deviance Residuals: 
    Min       1Q   Median       3Q      Max  
-7.7608  -1.2273   0.2032   1.3923   8.1617  

Coefficients:
                                      Estimate Std. Error t value Pr(>|t|)    
(Intercept)                          1.7757346  0.7652361   2.321 0.020338 *  
TV0.142857142857143                  0.2720987  0.2470266   1.101 0.270713    
TV0.285714285714286                  0.2618030  0.2274711   1.151 0.249795    
TV0.428571428571429                  0.2466092  0.2208783   1.116 0.264243    
TV0.571428571428571                  0.1777130  0.2203637   0.806 0.420005    
TV0.714285714285714                  0.2285287  0.2209291   1.034 0.300980    
TV0.857142857142858                  0.1240131  0.2266135   0.547 0.584225    
TV1                                  0.2155118  0.2310740   0.933 0.351026    
`Electronic games`0.142857142857143 -0.0003018  0.0775728  -0.004 0.996896    
`Electronic games`0.285714285714286  0.0812694  0.0832705   0.976 0.329108    
`Electronic games`0.428571428571429 -0.0574000  0.0794143  -0.723 0.469828    
`Electronic games`0.571428571428571  0.0808128  0.0842594   0.959 0.337539    
`Electronic games`0.714285714285714 -0.0209133  0.0873734  -0.239 0.810836    
`Electronic games`0.857142857142858 -0.0442727  0.1085745  -0.408 0.683458    
`Electronic games`1                 -0.0477170  0.1123467  -0.425 0.671045    
`Social media`0.142857142857143     -0.2718022  0.1298080  -2.094 0.036301 *  
`Social media`0.285714285714286     -0.3676444  0.1236514  -2.973 0.002955 ** 
`Social media`0.428571428571429     -0.4798486  0.1283604  -3.738 0.000187 ***
`Social media`0.571428571428571     -0.3926798  0.1316486  -2.983 0.002865 ** 
`Social media`0.714285714285714     -0.4156313  0.1326538  -3.133 0.001735 ** 
`Social media`0.857142857142858     -0.6370907  0.1468671  -4.338 1.46e-05 ***
`Social media`1                     -0.3913747  0.1535641  -2.549 0.010833 *  
`Other internet`0.142857142857142   -0.1023086  0.0878248  -1.165 0.244086    
`Other internet`0.142857142857143   -0.2298491  0.0783178  -2.935 0.003346 ** 
`Other internet`0.285714285714285   -0.1447690  0.1324885  -1.093 0.274561    
`Other internet`0.285714285714286   -0.1784700  0.0922269  -1.935 0.053010 .  
`Other internet`0.285714285714287   -0.3926545  0.1525598  -2.574 0.010077 *  
`Other internet`0.428571428571428   -0.4208802  0.1775478  -2.371 0.017786 *  
`Other internet`0.428571428571429   -0.3553279  0.1026149  -3.463 0.000537 ***
`Other internet`0.571428571428571   -0.3371418  0.1269559  -2.656 0.007932 ** 
`Other internet`0.571428571428572   -0.2258101  0.2147649  -1.051 0.293092    
`Other internet`0.714285714285714   -0.6300859  0.2496478  -2.524 0.011624 *  
`Other internet`0.714285714285715   -0.5415232  0.1817279  -2.980 0.002892 ** 
`Other internet`0.857142857142857   -0.3183545  0.2503894  -1.271 0.203608    
`Other internet`0.857142857142858   -0.5232188  0.2980083  -1.756 0.079173 .  
`Other internet`1                   -0.5559196  0.2935283  -1.894 0.058270 .  
`Own computer`1                      0.0823300  0.0625243   1.317 0.187953    
Male                                 1.1351643  0.0546939  20.755  < 2e-16 ***
Age                                 -0.0001453  0.0491081  -0.003 0.997640    
BMI                                 -0.0768521  0.0055695 -13.799  < 2e-16 ***
Motivation                           1.3316995  0.0515899  25.813  < 2e-16 ***
Ethnicity                           -0.0252797  0.0733463  -0.345 0.730357    
Closeness                            0.5886535  0.0375715  15.668  < 2e-16 ***
Father                               0.0254151  0.0570684   0.445 0.656082    
Score                               -0.0193531  0.0060860  -3.180 0.001478 ** 
Employed                             0.0041066  0.0606367   0.068 0.946007    
Illness                             -0.2976039  0.0618279  -4.813 1.51e-06 ***
Time                                 0.0767721  0.0262630   2.923 0.003474 ** 
Distress                            -0.0048488  0.0057829  -0.838 0.401787    
Siblings                             0.0431321  0.0237249   1.818 0.069099 .  
Income                               0.0002041  0.0001814   1.125 0.260515    
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

(Dispersion parameter for gaussian family taken to be 4.008234)

    Null deviance: 45236  on 8400  degrees of freedom
Residual deviance: 33469  on 8350  degrees of freedom
AIC: 35557

Number of Fisher Scoring iterations: 2

2.3.2.11 Outcome: Happy with family

Call:
glm(formula = y ~ ., data = datareg)

Deviance Residuals: 
    Min       1Q   Median       3Q      Max  
-9.4137  -0.5773   0.3399   1.0561   5.5462  

Coefficients:
                                      Estimate Std. Error t value Pr(>|t|)    
(Intercept)                          1.8343454  0.6708335   2.734 0.006262 ** 
TV0.142857142857143                  0.2648938  0.2175167   1.218 0.223331    
TV0.285714285714286                  0.1870336  0.2004431   0.933 0.350795    
TV0.428571428571429                  0.1876123  0.1946889   0.964 0.335248    
TV0.571428571428571                  0.2479161  0.1942333   1.276 0.201855    
TV0.714285714285714                  0.2640478  0.1946918   1.356 0.175061    
TV0.857142857142858                  0.3496129  0.1996335   1.751 0.079935 .  
TV1                                  0.2523816  0.2034882   1.240 0.214908    
`Electronic games`0.142857142857143  0.0021579  0.0679984   0.032 0.974685    
`Electronic games`0.285714285714286  0.0537650  0.0729980   0.737 0.461431    
`Electronic games`0.428571428571429  0.0465901  0.0696158   0.669 0.503356    
`Electronic games`0.571428571428571  0.0454323  0.0738386   0.615 0.538379    
`Electronic games`0.714285714285714  0.0380734  0.0765637   0.497 0.619006    
`Electronic games`0.857142857142858 -0.0276206  0.0951201  -0.290 0.771536    
`Electronic games`1                  0.1327786  0.0984143   1.349 0.177316    
`Social media`0.142857142857143     -0.2181551  0.1138021  -1.917 0.055276 .  
`Social media`0.285714285714286     -0.0788915  0.1084421  -0.727 0.466941    
`Social media`0.428571428571429     -0.2306460  0.1125742  -2.049 0.040509 *  
`Social media`0.571428571428571     -0.1445080  0.1154246  -1.252 0.210616    
`Social media`0.714285714285714     -0.1761793  0.1163170  -1.515 0.129899    
`Social media`0.857142857142858     -0.1985265  0.1287272  -1.542 0.123056    
`Social media`1                     -0.2769297  0.1345054  -2.059 0.039537 *  
`Other internet`0.142857142857142    0.0618080  0.0769731   0.803 0.422008    
`Other internet`0.142857142857143   -0.0332643  0.0687160  -0.484 0.628339    
`Other internet`0.285714285714285    0.1069173  0.1161814   0.920 0.357463    
`Other internet`0.285714285714286    0.0749619  0.0809253   0.926 0.354312    
`Other internet`0.285714285714287   -0.1161789  0.1337646  -0.869 0.385128    
`Other internet`0.428571428571428    0.0575846  0.1556614   0.370 0.711440    
`Other internet`0.428571428571429   -0.0670090  0.0900779  -0.744 0.456957    
`Other internet`0.571428571428571    0.0080742  0.1113166   0.073 0.942179    
`Other internet`0.571428571428572    0.0409407  0.1883014   0.217 0.827886    
`Other internet`0.714285714285714   -0.2831348  0.2178928  -1.299 0.193835    
`Other internet`0.714285714285715   -0.1056045  0.1590063  -0.664 0.506611    
`Other internet`0.857142857142857    0.1667296  0.2195188   0.760 0.447561    
`Other internet`0.857142857142858   -0.3829521  0.2612552  -1.466 0.142736    
`Other internet`1                   -0.3046174  0.2573308  -1.184 0.236543    
`Own computer`1                      0.0749913  0.0548809   1.366 0.171839    
Male                                 0.0798076  0.0479329   1.665 0.095953 .  
Age                                  0.0644554  0.0430400   1.498 0.134283    
BMI                                 -0.0162579  0.0048814  -3.331 0.000871 ***
Motivation                           0.7322697  0.0452170  16.195  < 2e-16 ***
Ethnicity                            0.4533060  0.0643518   7.044 2.01e-12 ***
Closeness                            1.1574893  0.0329457  35.133  < 2e-16 ***
Father                              -0.2835815  0.0500544  -5.665 1.51e-08 ***
Score                               -0.0204163  0.0053355  -3.827 0.000131 ***
Employed                            -0.0333392  0.0531172  -0.628 0.530248    
Illness                             -0.1343118  0.0541490  -2.480 0.013143 *  
Time                                 0.0342152  0.0230103   1.487 0.137065    
Distress                            -0.0145218  0.0050753  -2.861 0.004230 ** 
Siblings                             0.0044534  0.0207965   0.214 0.830442    
Income                               0.0001815  0.0001591   1.141 0.254014    
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

(Dispersion parameter for gaussian family taken to be 3.080447)

    Null deviance: 34113  on 8402  degrees of freedom
Residual deviance: 25728  on 8352  degrees of freedom
AIC: 33354

Number of Fisher Scoring iterations: 2

2.3.2.12 Outcome: Happy with friends

Call:
glm(formula = y ~ ., data = datareg)

Deviance Residuals: 
    Min       1Q   Median       3Q      Max  
-8.6946  -0.6170   0.3712   1.1950   3.7297  

Coefficients:
                                      Estimate Std. Error t value Pr(>|t|)    
(Intercept)                          3.1250476  0.6984863   4.474 7.78e-06 ***
TV0.142857142857143                  0.5255048  0.2254737   2.331 0.019794 *  
TV0.285714285714286                  0.5160945  0.2077159   2.485 0.012989 *  
TV0.428571428571429                  0.4547739  0.2017026   2.255 0.024179 *  
TV0.571428571428571                  0.4842436  0.2012259   2.406 0.016129 *  
TV0.714285714285714                  0.5647796  0.2017290   2.800 0.005127 ** 
TV0.857142857142858                  0.4668689  0.2069107   2.256 0.024073 *  
TV1                                  0.4367743  0.2109793   2.070 0.038462 *  
`Electronic games`0.142857142857143 -0.0885338  0.0708288  -1.250 0.211346    
`Electronic games`0.285714285714286  0.0468691  0.0760323   0.616 0.537623    
`Electronic games`0.428571428571429 -0.0394942  0.0725127  -0.545 0.586007    
`Electronic games`0.571428571428571  0.0554361  0.0768949   0.721 0.470971    
`Electronic games`0.714285714285714 -0.1347431  0.0797338  -1.690 0.091082 .  
`Electronic games`0.857142857142858  0.0111847  0.0990612   0.113 0.910107    
`Electronic games`1                  0.0630750  0.1024512   0.616 0.538136    
`Social media`0.142857142857143     -0.0662256  0.1186422  -0.558 0.576725    
`Social media`0.285714285714286      0.0350440  0.1130178   0.310 0.756511    
`Social media`0.428571428571429      0.0443827  0.1173678   0.378 0.705328    
`Social media`0.571428571428571      0.1607806  0.1203361   1.336 0.181554    
`Social media`0.714285714285714      0.0964966  0.1212538   0.796 0.426157    
`Social media`0.857142857142858      0.0382709  0.1341776   0.285 0.775479    
`Social media`1                      0.2413502  0.1402975   1.720 0.085420 .  
`Other internet`0.142857142857142    0.0791885  0.0801940   0.987 0.323445    
`Other internet`0.142857142857143    0.0252894  0.0715289   0.354 0.723681    
`Other internet`0.285714285714285   -0.0639651  0.1208969  -0.529 0.596758    
`Other internet`0.285714285714286    0.0849557  0.0842496   1.008 0.313301    
`Other internet`0.285714285714287   -0.1621270  0.1393163  -1.164 0.244565    
`Other internet`0.428571428571428    0.0661010  0.1621702   0.408 0.683576    
`Other internet`0.428571428571429   -0.0688922  0.0937378  -0.735 0.462393    
`Other internet`0.571428571428571   -0.0701426  0.1160994  -0.604 0.545754    
`Other internet`0.571428571428572    0.1984801  0.1961168   1.012 0.311543    
`Other internet`0.714285714285714   -0.3366503  0.2270477  -1.483 0.138184    
`Other internet`0.714285714285715    0.1420697  0.1656100   0.858 0.390996    
`Other internet`0.857142857142857    0.0502383  0.2286636   0.220 0.826107    
`Other internet`0.857142857142858   -0.3894194  0.2722028  -1.431 0.152576    
`Other internet`1                   -0.3795401  0.2681131  -1.416 0.156931    
`Own computer`1                      0.0052652  0.0570979   0.092 0.926531    
Male                                 0.1714827  0.0499195   3.435 0.000595 ***
Age                                  0.0339955  0.0448298   0.758 0.448279    
BMI                                 -0.0055915  0.0050864  -1.099 0.271669    
Motivation                           0.8306244  0.0470463  17.655  < 2e-16 ***
Ethnicity                            0.2109614  0.0669572   3.151 0.001635 ** 
Closeness                            0.5321714  0.0343005  15.515  < 2e-16 ***
Father                              -0.0471037  0.0520900  -0.904 0.365875    
Score                               -0.0174182  0.0055546  -3.136 0.001720 ** 
Employed                             0.0113744  0.0553455   0.206 0.837174    
Illness                             -0.3002223  0.0564157  -5.322 1.06e-07 ***
Time                                 0.0056574  0.0239581   0.236 0.813330    
Distress                            -0.0111971  0.0052826  -2.120 0.034070 *  
Siblings                             0.0014574  0.0216617   0.067 0.946362    
Income                               0.0000808  0.0001656   0.488 0.625562    
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

(Dispersion parameter for gaussian family taken to be 3.342385)

    Null deviance: 31579  on 8407  degrees of freedom
Residual deviance: 27932  on 8357  degrees of freedom
AIC: 34060

Number of Fisher Scoring iterations: 2

2.3.2.13 Outcome: Happy with school

Call:
glm(formula = y ~ ., data = datareg)

Deviance Residuals: 
    Min       1Q   Median       3Q      Max  
-8.8488  -0.9365   0.3158   1.2564   6.5888  

Coefficients:
                                      Estimate Std. Error t value Pr(>|t|)    
(Intercept)                         -1.9954487  0.7367170  -2.709 0.006771 ** 
TV0.142857142857143                  0.4369441  0.2388240   1.830 0.067351 .  
TV0.285714285714286                  0.4826724  0.2200775   2.193 0.028321 *  
TV0.428571428571429                  0.5286126  0.2137631   2.473 0.013422 *  
TV0.571428571428571                  0.4851268  0.2132990   2.274 0.022967 *  
TV0.714285714285714                  0.5443142  0.2138519   2.545 0.010937 *  
TV0.857142857142858                  0.3812909  0.2192819   1.739 0.082104 .  
TV1                                  0.3211253  0.2235269   1.437 0.150861    
`Electronic games`0.142857142857143  0.0658987  0.0746528   0.883 0.377405    
`Electronic games`0.285714285714286  0.0136642  0.0801108   0.171 0.864569    
`Electronic games`0.428571428571429 -0.0451559  0.0764585  -0.591 0.554808    
`Electronic games`0.571428571428571  0.0283800  0.0810687   0.350 0.726292    
`Electronic games`0.714285714285714  0.0029760  0.0841104   0.035 0.971776    
`Electronic games`0.857142857142858 -0.1102686  0.1044425  -1.056 0.291098    
`Electronic games`1                 -0.1210159  0.1080655  -1.120 0.262815    
`Social media`0.142857142857143     -0.1521260  0.1250545  -1.216 0.223837    
`Social media`0.285714285714286     -0.0347314  0.1190762  -0.292 0.770543    
`Social media`0.428571428571429     -0.1115766  0.1236427  -0.902 0.366864    
`Social media`0.571428571428571      0.0582377  0.1267751   0.459 0.645975    
`Social media`0.714285714285714      0.0710362  0.1277677   0.556 0.578240    
`Social media`0.857142857142858     -0.1493186  0.1413329  -1.057 0.290769    
`Social media`1                     -0.0685832  0.1478142  -0.464 0.642673    
`Other internet`0.142857142857142    0.0814053  0.0844915   0.963 0.335338    
`Other internet`0.142857142857143   -0.1014915  0.0754106  -1.346 0.178387    
`Other internet`0.285714285714285    0.2576413  0.1274345   2.022 0.043233 *  
`Other internet`0.285714285714286    0.0332793  0.0888612   0.375 0.708035    
`Other internet`0.285714285714287    0.0133168  0.1468626   0.091 0.927753    
`Other internet`0.428571428571428    0.1449294  0.1706336   0.849 0.395705    
`Other internet`0.428571428571429    0.0492052  0.0988019   0.498 0.618484    
`Other internet`0.571428571428571    0.1738501  0.1223429   1.421 0.155352    
`Other internet`0.571428571428572   -0.3237142  0.2067473  -1.566 0.117445    
`Other internet`0.714285714285714    0.0088533  0.2392818   0.037 0.970486    
`Other internet`0.714285714285715    0.2017849  0.1745985   1.156 0.247833    
`Other internet`0.857142857142857    0.2424160  0.2410662   1.006 0.314637    
`Other internet`0.857142857142858   -0.2419535  0.2868963  -0.843 0.399058    
`Other internet`1                   -0.2597488  0.2825784  -0.919 0.358012    
`Own computer`1                      0.0952570  0.0602188   1.582 0.113722    
Male                                 0.1418009  0.0526155   2.695 0.007052 ** 
Age                                  0.0916298  0.0472438   1.940 0.052473 .  
BMI                                 -0.0149743  0.0053606  -2.793 0.005228 ** 
Motivation                           1.9542871  0.0496576  39.355  < 2e-16 ***
Ethnicity                            0.1254981  0.0705844   1.778 0.075442 .  
Closeness                            0.3843360  0.0361405  10.635  < 2e-16 ***
Father                              -0.0488787  0.0549148  -0.890 0.373447    
Score                                0.0213132  0.0058548   3.640 0.000274 ***
Employed                             0.0147060  0.0583092   0.252 0.800888    
Illness                             -0.2613623  0.0594399  -4.397 1.11e-05 ***
Time                                 0.0190451  0.0252723   0.754 0.451112    
Distress                            -0.0101446  0.0055659  -1.823 0.068393 .  
Siblings                             0.0342839  0.0228408   1.501 0.133395    
Income                               0.0005851  0.0001746   3.352 0.000807 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

(Dispersion parameter for gaussian family taken to be 3.714398)

    Null deviance: 42169  on 8406  degrees of freedom
Residual deviance: 31038  on 8356  degrees of freedom
AIC: 34943

Number of Fisher Scoring iterations: 2

2.3.2.14 Outcome: Happy with life

Call:
glm(formula = y ~ ., data = datareg)

Deviance Residuals: 
    Min       1Q   Median       3Q      Max  
-9.1850  -0.8275   0.2663   1.1588   5.3200  

Coefficients:
                                      Estimate Std. Error t value Pr(>|t|)    
(Intercept)                          4.578e-01  6.847e-01   0.669 0.503761    
TV0.142857142857143                  2.546e-01  2.211e-01   1.151 0.249658    
TV0.285714285714286                  3.503e-01  2.035e-01   1.721 0.085240 .  
TV0.428571428571429                  3.417e-01  1.976e-01   1.729 0.083861 .  
TV0.571428571428571                  3.354e-01  1.972e-01   1.701 0.089014 .  
TV0.714285714285714                  3.284e-01  1.977e-01   1.661 0.096682 .  
TV0.857142857142858                  2.852e-01  2.028e-01   1.407 0.159570    
TV1                                  2.477e-01  2.067e-01   1.198 0.230984    
`Electronic games`0.142857142857143  2.725e-02  6.943e-02   0.393 0.694687    
`Electronic games`0.285714285714286  1.314e-01  7.456e-02   1.762 0.078068 .  
`Electronic games`0.428571428571429 -8.784e-02  7.109e-02  -1.236 0.216637    
`Electronic games`0.571428571428571  4.793e-02  7.540e-02   0.636 0.524961    
`Electronic games`0.714285714285714 -7.082e-02  7.822e-02  -0.905 0.365276    
`Electronic games`0.857142857142858 -6.804e-02  9.710e-02  -0.701 0.483528    
`Electronic games`1                  4.285e-02  1.006e-01   0.426 0.670096    
`Social media`0.142857142857143     -1.580e-01  1.164e-01  -1.357 0.174668    
`Social media`0.285714285714286     -1.303e-01  1.108e-01  -1.175 0.239976    
`Social media`0.428571428571429     -1.979e-01  1.151e-01  -1.719 0.085651 .  
`Social media`0.571428571428571      2.764e-04  1.181e-01   0.002 0.998132    
`Social media`0.714285714285714     -1.618e-01  1.190e-01  -1.360 0.173828    
`Social media`0.857142857142858     -3.210e-01  1.316e-01  -2.439 0.014751 *  
`Social media`1                     -2.688e-01  1.376e-01  -1.953 0.050829 .  
`Other internet`0.142857142857142    1.026e-02  7.860e-02   0.131 0.896111    
`Other internet`0.142857142857143   -1.598e-01  7.016e-02  -2.278 0.022749 *  
`Other internet`0.285714285714285    5.274e-03  1.185e-01   0.045 0.964492    
`Other internet`0.285714285714286   -6.533e-02  8.258e-02  -0.791 0.428929    
`Other internet`0.285714285714287   -4.294e-01  1.365e-01  -3.145 0.001668 ** 
`Other internet`0.428571428571428   -2.643e-01  1.589e-01  -1.663 0.096363 .  
`Other internet`0.428571428571429   -1.445e-01  9.187e-02  -1.573 0.115809    
`Other internet`0.571428571428571   -1.690e-01  1.138e-01  -1.485 0.137531    
`Other internet`0.571428571428572   -2.610e-01  1.922e-01  -1.358 0.174442    
`Other internet`0.714285714285714   -3.299e-01  2.225e-01  -1.482 0.138280    
`Other internet`0.714285714285715   -1.679e-01  1.623e-01  -1.034 0.301028    
`Other internet`0.857142857142857   -2.309e-01  2.241e-01  -1.030 0.302831    
`Other internet`0.857142857142858   -6.113e-01  2.667e-01  -2.292 0.021948 *  
`Other internet`1                   -3.461e-01  2.628e-01  -1.317 0.187870    
`Own computer`1                      6.133e-02  5.598e-02   1.096 0.273307    
Male                                 5.817e-01  4.894e-02  11.886  < 2e-16 ***
Age                                  4.478e-02  4.393e-02   1.019 0.308117    
BMI                                 -2.837e-02  4.990e-03  -5.686 1.34e-08 ***
Motivation                           1.378e+00  4.619e-02  29.831  < 2e-16 ***
Ethnicity                            3.764e-01  6.565e-02   5.734 1.01e-08 ***
Closeness                            7.847e-01  3.364e-02  23.326  < 2e-16 ***
Father                              -1.427e-01  5.108e-02  -2.794 0.005225 ** 
Score                               -1.783e-02  5.445e-03  -3.274 0.001066 ** 
Employed                             6.145e-02  5.423e-02   1.133 0.257234    
Illness                             -3.797e-01  5.534e-02  -6.860 7.35e-12 ***
Time                                 2.294e-02  2.350e-02   0.976 0.329047    
Distress                            -1.978e-02  5.177e-03  -3.820 0.000134 ***
Siblings                             3.369e-02  2.124e-02   1.586 0.112688    
Income                               1.121e-05  1.623e-04   0.069 0.944910    
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

(Dispersion parameter for gaussian family taken to be 3.208938)

    Null deviance: 37208  on 8396  degrees of freedom
Residual deviance: 26782  on 8346  degrees of freedom
AIC: 33673

Number of Fisher Scoring iterations: 2

2.4 LINEAR ANALYSIS

Original outcome variables are not binary. Use linear regression.

Run both MLE and Baysian model selection for each outcome. Model selection is done with one outcome, all treatment and all control variables. This gives some 130k models – enumeration using modelSelectionGLM() is not feasible. Instead, we use modelSelection() and Gibbs sampling with Zellner’s coefficient prior (\(τ=n\) \(⇒\) unit information) and a beta-binomial model prior (making the model probabilities roughly equal to the EBIC).

2.4.1 Regressions

Weekday electronic games has negative effect on all outcomes. Social media hours has positive effect on peer problems, prosocial behaviour and total difficulties. The treatments generally have little/no impact on conduct problems and hyperactivity (which may have more to do with other factors and are, arguably, poor measures of well-being).

Opposite association of internet/social media usage with depression, compared to “emotional symptoms” assessment by parents. We find this result when only one variable is included, otherwise social media is significant/included in parents (emotional symptoms) whereas internet is significant/included in cohort member models. Electronic games, which generally had a negative effect in parent’s assessments, has little effect.

y= data[,y_all]; names(y)= names(y_all)

idys= c(1:dim(y)[2])
idx= 1:dim(x)[2]
mcs_lme= list()
mcs_ms= list()

for (idy in idys) {
  datareg= na.omit(data.frame(y[,idy], x[,idx], data[,c(cvars)]))
  names(datareg)[1]= 'y'
  names(datareg)[2:(1+length(idx))]= names(x)[idx]
  names(datareg)[-(1:(1+length(idx)))]= names(cvars)
  y_name= names(y)[idy]
  
  # MLE
  mcs_lme[[y_name]]= glm(y ~ ., data=datareg)
  cat("#### ", 'Outcome: ', y_name, ' (MLE) \n')
  cat.asis(summary(mcs_lme[[y_name]]))
  
  # Model selection
  mcs_ms[[y_name]]= mombf:::modelSelection(y ~ ., data=datareg, includevars=1, priorCoef=zellnerprior(tau=dim(datareg)[1]), priorDelta==modelbbprior(1,1), verbose=FALSE)
  cat("#### ", 'Outcome: ', y_name, ' (model selection) \n\n')
  cat.asis(format(coef(mcs_ms[[y_name]]), digits=1, scientific=FALSE), pre='\n')
}

2.4.1.1 Outcome: Depression (adolescent) (MLE)

Call:
glm(formula = y ~ ., data = datareg)

Deviance Residuals: 
    Min       1Q   Median       3Q      Max  
-4.9930  -1.0509  -0.2725   0.7450   8.1035  

Coefficients:
                     Estimate Std. Error t value Pr(>|t|)    
(Intercept)         8.4399959  0.5982988  14.107  < 2e-16 ***
TV                  0.1019676  0.0908555   1.122 0.261765    
`Electronic games`  0.0561670  0.0726499   0.773 0.439474    
`Social media`      0.4568017  0.0958515   4.766 1.91e-06 ***
`Other internet`    0.4749259  0.0966272   4.915 9.05e-07 ***
`Own computer`     -0.0429164  0.0509086  -0.843 0.399247    
Male               -0.8260795  0.0443199 -18.639  < 2e-16 ***
Age                 0.0408476  0.0400748   1.019 0.308098    
BMI                 0.0349892  0.0045625   7.669 1.93e-14 ***
Motivation         -1.4855349  0.0420298 -35.345  < 2e-16 ***
Ethnicity          -0.1483989  0.0599268  -2.476 0.013293 *  
Closeness          -0.6287346  0.0306689 -20.501  < 2e-16 ***
Father             -0.0001285  0.0466920  -0.003 0.997805    
Score               0.0167989  0.0049763   3.376 0.000739 ***
Employed           -0.0459696  0.0495039  -0.929 0.353120    
Illness             0.3937407  0.0505007   7.797 7.12e-15 ***
Time               -0.0274854  0.0214632  -1.281 0.200375    
Distress            0.0168594  0.0047263   3.567 0.000363 ***
Siblings           -0.0437827  0.0193891  -2.258 0.023965 *  
Income              0.0001051  0.0001483   0.709 0.478492    
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

(Dispersion parameter for gaussian family taken to be 2.668779)

    Null deviance: 33174  on 8350  degrees of freedom
Residual deviance: 22234  on 8331  degrees of freedom
AIC: 31919

Number of Fisher Scoring iterations: 2

2.4.1.2 Outcome: Depression (adolescent) (model selection)

                    estimate    2.5%        97.5%       margpp     
(Intercept)        " 8.737267" " 8.346274" " 9.152750" " 0.000000"
TV                 " 0.002986" " 0.000000" " 0.000000" " 0.026221"
`Electronic games` " 0.000737" " 0.000000" " 0.000000" " 0.015802"
`Social media`     " 0.508918" " 0.340792" " 0.676819" " 0.999989"
`Other internet`   " 0.527154" " 0.408523" " 0.646664" " 0.999995"
`Own computer`     "-0.000414" " 0.000000" " 0.000000" " 0.015491"
Male               "-0.808768" "-0.859274" "-0.758890" " 1.000000"
Age                " 0.000704" " 0.000000" " 0.000000" " 0.019940"
BMI                " 0.035337" " 0.027919" " 0.042723" " 1.000000"
Motivation         "-1.480657" "-1.549677" "-1.410926" " 1.000000"
Ethnicity          "-0.012349" "-0.140821" " 0.000000" " 0.104393"
Closeness          "-0.630152" "-0.675899" "-0.584344" " 1.000000"
Father             "-0.000107" " 0.000000" " 0.000000" " 0.013029"
Score              " 0.015155" " 0.000000" " 0.023571" " 0.915358"
Employed           "-0.000063" " 0.000000" " 0.000000" " 0.013425"
Illness            " 0.395362" " 0.320136" " 0.469639" " 1.000000"
Time               "-0.000430" " 0.000000" " 0.000000" " 0.020616"
Distress           " 0.016402" " 0.000000" " 0.024574" " 0.934932"
Siblings           "-0.004792" "-0.051351" " 0.000000" " 0.125584"
Income             " 0.000006" " 0.000000" " 0.000069" " 0.035224"
phi                " 2.668959" " 2.590555" " 2.751050" " 1.000000"

2.4.1.3 Outcome: Self-esteem (adolescent) (MLE)

Call:
glm(formula = y ~ ., data = datareg)

Deviance Residuals: 
    Min       1Q   Median       3Q      Max  
-5.1526  -0.9611   0.1011   0.9113   7.2462  

Coefficients:
                     Estimate Std. Error t value Pr(>|t|)    
(Intercept)         8.7687024  0.5293746  16.564  < 2e-16 ***
TV                  0.0370016  0.0803654   0.460  0.64523    
`Electronic games`  0.0319610  0.0642428   0.498  0.61885    
`Social media`      0.0491193  0.0847892   0.579  0.56240    
`Other internet`    0.3605685  0.0855197   4.216 2.51e-05 ***
`Own computer`     -0.0066247  0.0450231  -0.147  0.88303    
Male               -0.8076568  0.0391976 -20.605  < 2e-16 ***
Age                -0.0193881  0.0354572  -0.547  0.58453    
BMI                 0.0335768  0.0040300   8.332  < 2e-16 ***
Motivation         -1.1707098  0.0371823 -31.486  < 2e-16 ***
Ethnicity           0.1356715  0.0529167   2.564  0.01037 *  
Closeness          -0.4717141  0.0271811 -17.354  < 2e-16 ***
Father              0.0349182  0.0412990   0.845  0.39786    
Score               0.0000742  0.0043989   0.017  0.98654    
Employed            0.0006666  0.0438901   0.015  0.98788    
Illness             0.2509636  0.0447546   5.608 2.12e-08 ***
Time               -0.0530321  0.0189793  -2.794  0.00521 ** 
Distress            0.0058847  0.0041938   1.403  0.16060    
Siblings           -0.0134480  0.0172098  -0.781  0.43458    
Income             -0.0001617  0.0001311  -1.234  0.21734    
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

(Dispersion parameter for gaussian family taken to be 2.081348)

    Null deviance: 24087  on 8310  degrees of freedom
Residual deviance: 17256  on 8291  degrees of freedom
AIC: 29700

Number of Fisher Scoring iterations: 2

2.4.1.4 Outcome: Self-esteem (adolescent) (model selection)

                    estimate    2.5%        97.5%       margpp     
(Intercept)        " 8.643764" " 8.297253" " 8.950539" " 0.000000"
TV                 " 0.001075" " 0.000000" " 0.000000" " 0.014213"
`Electronic games` " 0.001681" " 0.000000" " 0.000000" " 0.020066"
`Social media`     " 0.001819" " 0.000000" " 0.000000" " 0.020217"
`Other internet`   " 0.331299" " 0.222526" " 0.442581" " 0.999883"
`Own computer`     " 0.000013" " 0.000000" " 0.000000" " 0.008398"
Male               "-0.800673" "-0.849399" "-0.752596" " 1.000000"
Age                "-0.000092" " 0.000000" " 0.000000" " 0.009246"
BMI                " 0.035024" " 0.028396" " 0.041670" " 1.000000"
Motivation         "-1.198000" "-1.261319" "-1.133004" " 1.000000"
Ethnicity          " 0.033423" " 0.000000" " 0.166704" " 0.250306"
Closeness          "-0.477627" "-0.518757" "-0.436219" " 1.000000"
Father             " 0.004893" " 0.000000" " 0.081829" " 0.068851"
Score              "-0.000011" " 0.000000" " 0.000000" " 0.009716"
Employed           "-0.000107" " 0.000000" " 0.000000" " 0.009309"
Illness            " 0.266475" " 0.198767" " 0.333813" " 0.999998"
Time               "-0.032829" "-0.085504" " 0.000000" " 0.549723"
Distress           " 0.000340" " 0.000000" " 0.007147" " 0.044202"
Siblings           "-0.000090" " 0.000000" " 0.000000" " 0.010840"
Income             "-0.000007" "-0.000146" " 0.000000" " 0.042642"
phi                " 2.082022" " 2.018825" " 2.147024" " 1.000000"

2.4.1.5 Outcome: Total difficulties (parent) (MLE)

Call:
glm(formula = y ~ ., data = datareg)

Deviance Residuals: 
    Min       1Q   Median       3Q      Max  
-3.3673  -0.7320  -0.1611   0.5797   6.0405  

Coefficients:
                     Estimate Std. Error t value Pr(>|t|)    
(Intercept)         3.686e+01  3.989e-01  92.411  < 2e-16 ***
TV                 -1.134e-02  6.063e-02  -0.187 0.851624    
`Electronic games`  2.440e-01  4.855e-02   5.026 5.10e-07 ***
`Social media`     -2.559e-01  6.405e-02  -3.996 6.51e-05 ***
`Other internet`    4.516e-02  6.453e-02   0.700 0.484056    
`Own computer`     -5.234e-02  3.408e-02  -1.536 0.124679    
Male                5.633e-02  2.967e-02   1.898 0.057670 .  
Age                -6.541e-02  2.676e-02  -2.444 0.014548 *  
BMI                 2.113e-02  3.044e-03   6.940 4.21e-12 ***
Motivation         -4.237e-01  2.804e-02 -15.109  < 2e-16 ***
Ethnicity           4.148e-02  4.011e-02   1.034 0.301127    
Closeness          -2.761e-01  2.050e-02 -13.468  < 2e-16 ***
Father              9.353e-02  3.119e-02   2.998 0.002723 ** 
Score              -3.450e-02  3.332e-03 -10.353  < 2e-16 ***
Employed           -1.209e-01  3.312e-02  -3.650 0.000264 ***
Illness             6.188e-01  3.372e-02  18.351  < 2e-16 ***
Time               -5.003e-02  1.435e-02  -3.486 0.000493 ***
Distress            7.437e-02  3.157e-03  23.559  < 2e-16 ***
Siblings           -3.489e-02  1.298e-02  -2.687 0.007216 ** 
Income             -6.826e-04  9.967e-05  -6.849 7.96e-12 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

(Dispersion parameter for gaussian family taken to be 1.180404)

    Null deviance: 13292.7  on 8237  degrees of freedom
Residual deviance:  9700.6  on 8218  degrees of freedom
AIC: 24767

Number of Fisher Scoring iterations: 2

2.4.1.6 Outcome: Total difficulties (parent) (model selection)

                    estimate  2.5%      97.5%     margpp   
(Intercept)        "36.1346" "35.5639" "37.2347" " 0.0000"
TV                 "-0.0003" " 0.0000" " 0.0000" " 0.0257"
`Electronic games` " 0.2973" " 0.2085" " 0.3694" " 1.0000"
`Social media`     "-0.3111" "-0.3922" "-0.2290" " 1.0000"
`Other internet`   " 0.0007" " 0.0000" " 0.0000" " 0.0281"
`Own computer`     "-0.0032" "-0.0582" " 0.0000" " 0.0683"
Male               " 0.0063" " 0.0000" " 0.0709" " 0.1221"
Age                "-0.0180" "-0.0942" " 0.0000" " 0.2905"
BMI                " 0.0207" " 0.0155" " 0.0259" " 1.0000"
Motivation         "-0.4277" "-0.4763" "-0.3786" " 1.0000"
Ethnicity          " 0.0017" " 0.0000" " 0.0277" " 0.0437"
Closeness          "-0.2757" "-0.3081" "-0.2430" " 1.0000"
Father             " 0.0926" " 0.0000" " 0.1589" " 0.8650"
Score              "-0.0333" "-0.0394" "-0.0272" " 1.0000"
Employed           "-0.0867" "-0.1433" " 0.0000" " 0.7747"
Illness            " 0.6220" " 0.5700" " 0.6727" " 1.0000"
Time               "-0.0395" "-0.0712" " 0.0000" " 0.8045"
Distress           " 0.0750" " 0.0695" " 0.0807" " 1.0000"
Siblings           "-0.0152" "-0.0543" " 0.0000" " 0.4325"
Income             "-0.0007" "-0.0009" "-0.0005" " 1.0000"
phi                " 1.1809" " 1.1458" " 1.2173" " 1.0000"

2.4.1.7 Outcome: Emotional problems (parent) (MLE)

Call:
glm(formula = y ~ ., data = datareg)

Deviance Residuals: 
    Min       1Q   Median       3Q      Max  
-4.7871  -1.1320  -0.4005   0.8727   7.6655  

Coefficients:
                     Estimate Std. Error t value Pr(>|t|)    
(Intercept)         4.2462817  0.6084044   6.979 3.20e-12 ***
TV                  0.0783084  0.0924836   0.847  0.39717    
`Electronic games`  0.2415033  0.0740568   3.261  0.00111 ** 
`Social media`     -0.4195891  0.0977056  -4.294 1.77e-05 ***
`Other internet`    0.0771434  0.0984387   0.784  0.43326    
`Own computer`      0.0284387  0.0519934   0.547  0.58442    
Male               -0.6761445  0.0452496 -14.943  < 2e-16 ***
Age                 0.0240718  0.0408191   0.590  0.55539    
BMI                 0.0192888  0.0046431   4.154 3.30e-05 ***
Motivation         -0.4635876  0.0427693 -10.839  < 2e-16 ***
Ethnicity           0.0502576  0.0611759   0.822  0.41137    
Closeness          -0.1276085  0.0312704  -4.081 4.53e-05 ***
Father              0.0808670  0.0475842   1.699  0.08927 .  
Score              -0.0307468  0.0050825  -6.050 1.52e-09 ***
Employed           -0.0891188  0.0505140  -1.764  0.07773 .  
Illness             0.9870553  0.0514411  19.188  < 2e-16 ***
Time               -0.0327552  0.0218935  -1.496  0.13466    
Distress            0.1103118  0.0048152  22.909  < 2e-16 ***
Siblings           -0.0447818  0.0198060  -2.261  0.02378 *  
Income             -0.0004161  0.0001520  -2.737  0.00621 ** 
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

(Dispersion parameter for gaussian family taken to be 2.747094)

    Null deviance: 28171  on 8239  degrees of freedom
Residual deviance: 22581  on 8220  degrees of freedom
AIC: 31733

Number of Fisher Scoring iterations: 2

2.4.1.8 Outcome: Emotional problems (parent) (model selection)

                    estimate  2.5%      97.5%     margpp   
(Intercept)        " 4.4737" " 3.9275" " 5.0096" " 0.0000"
TV                 " 0.0025" " 0.0000" " 0.0000" " 0.0272"
`Electronic games` " 0.2911" " 0.1305" " 0.4476" " 0.9862"
`Social media`     "-0.4350" "-0.5695" "-0.2926" " 0.9984"
`Other internet`   " 0.0034" " 0.0000" " 0.0419" " 0.0330"
`Own computer`     " 0.0008" " 0.0000" " 0.0000" " 0.0220"
Male               "-0.6860" "-0.7458" "-0.6212" " 1.0000"
Age                " 0.0004" " 0.0000" " 0.0000" " 0.0192"
BMI                " 0.0205" " 0.0122" " 0.0289" " 0.9959"
Motivation         "-0.4720" "-0.5524" "-0.3935" " 1.0000"
Ethnicity          " 0.0020" " 0.0000" " 0.0282" " 0.0295"
Closeness          "-0.1290" "-0.1808" "-0.0738" " 0.9865"
Father             " 0.0473" " 0.0000" " 0.1780" " 0.3565"
Score              "-0.0306" "-0.0409" "-0.0198" " 1.0000"
Employed           "-0.0038" "-0.0775" " 0.0000" " 0.0518"
Illness            " 0.9988" " 0.9175" " 1.0793" " 1.0000"
Time               "-0.0010" "-0.0157" " 0.0000" " 0.0378"
Distress           " 0.1131" " 0.1046" " 0.1216" " 1.0000"
Siblings           "-0.0113" "-0.0728" " 0.0000" " 0.2293"
Income             "-0.0003" "-0.0007" " 0.0000" " 0.7104"
phi                " 2.7470" " 2.6643" " 2.8310" " 1.0000"

2.4.1.9 Outcome: conduct problems (MLE)

Call:
glm(formula = y ~ ., data = datareg)

Deviance Residuals: 
    Min       1Q   Median       3Q      Max  
-3.1920  -0.8358  -0.2442   0.5982   6.7959  

Coefficients:
                     Estimate Std. Error t value Pr(>|t|)    
(Intercept)         5.2143005  0.4473997  11.655  < 2e-16 ***
TV                 -0.1627947  0.0679999  -2.394  0.01669 *  
`Electronic games`  0.1093483  0.0544637   2.008  0.04470 *  
`Social media`      0.0368279  0.0718397   0.513  0.60822    
`Other internet`   -0.1537985  0.0723837  -2.125  0.03364 *  
`Own computer`     -0.1001224  0.0382211  -2.620  0.00882 ** 
Male                0.1508683  0.0332716   4.534 5.86e-06 ***
Age                -0.0514355  0.0300150  -1.714  0.08663 .  
BMI                 0.0174865  0.0034139   5.122 3.09e-07 ***
Motivation         -0.2845166  0.0314482  -9.047  < 2e-16 ***
Ethnicity           0.0993330  0.0449486   2.210  0.02714 *  
Closeness          -0.4747225  0.0229956 -20.644  < 2e-16 ***
Father              0.0760336  0.0349810   2.174  0.02977 *  
Score              -0.0285456  0.0037355  -7.642 2.38e-14 ***
Employed           -0.0890983  0.0371355  -2.399  0.01645 *  
Illness             0.2525213  0.0378248   6.676 2.61e-11 ***
Time               -0.0275289  0.0160990  -1.710  0.08731 .  
Distress            0.0487180  0.0035374  13.772  < 2e-16 ***
Siblings            0.0386682  0.0145558   2.657  0.00791 ** 
Income             -0.0006664  0.0001118  -5.962 2.60e-09 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

(Dispersion parameter for gaussian family taken to be 1.485474)

    Null deviance: 14979  on 8242  degrees of freedom
Residual deviance: 12215  on 8223  degrees of freedom
AIC: 26677

Number of Fisher Scoring iterations: 2

2.4.1.10 Outcome: conduct problems (model selection)

                    estimate  2.5%      97.5%     margpp   
(Intercept)        " 4.6716" " 4.2585" " 5.2157" " 0.0000"
TV                 "-0.0208" "-0.1981" " 0.0000" " 0.1620"
`Electronic games` " 0.0050" " 0.0000" " 0.0995" " 0.0711"
`Social media`     " 0.0038" " 0.0000" " 0.0820" " 0.0558"
`Other internet`   "-0.1002" "-0.2571" " 0.0000" " 0.6022"
`Own computer`     "-0.0440" "-0.1536" " 0.0000" " 0.4193"
Male               " 0.1778" " 0.1267" " 0.2269" " 0.9999"
Age                "-0.0021" "-0.0424" " 0.0000" " 0.0575"
BMI                " 0.0166" " 0.0104" " 0.0227" " 0.9993"
Motivation         "-0.2940" "-0.3525" "-0.2355" " 1.0000"
Ethnicity          " 0.0283" " 0.0000" " 0.1437" " 0.2590"
Closeness          "-0.4794" "-0.5175" "-0.4418" " 1.0000"
Father             " 0.0084" " 0.0000" " 0.0894" " 0.1282"
Score              "-0.0264" "-0.0339" "-0.0190" " 1.0000"
Employed           "-0.0099" "-0.0970" " 0.0000" " 0.1436"
Illness            " 0.2580" " 0.1977" " 0.3198" " 1.0000"
Time               "-0.0016" "-0.0312" " 0.0000" " 0.0724"
Distress           " 0.0500" " 0.0438" " 0.0563" " 1.0000"
Siblings           " 0.0132" " 0.0000" " 0.0596" " 0.3497"
Income             "-0.0009" "-0.0010" "-0.0007" " 1.0000"
phi                " 1.4892" " 1.4449" " 1.5352" " 1.0000"

2.4.1.11 Outcome: hyperactivity/inattention (MLE)

Call:
glm(formula = y ~ ., data = datareg)

Deviance Residuals: 
   Min      1Q  Median      3Q     Max  
-5.244  -1.365  -0.256   1.137   7.652  

Coefficients:
                     Estimate Std. Error t value Pr(>|t|)    
(Intercept)         9.6565609  0.6930351  13.934  < 2e-16 ***
TV                 -0.1239925  0.1053402  -1.177 0.239203    
`Electronic games`  0.2149694  0.0843572   2.548 0.010842 *  
`Social media`     -0.0783199  0.1112869  -0.704 0.481599    
`Other internet`   -0.2449812  0.1121276  -2.185 0.028929 *  
`Own computer`     -0.1518958  0.0592236  -2.565 0.010342 *  
Male                0.8354931  0.0515375  16.211  < 2e-16 ***
Age                -0.1592267  0.0464946  -3.425 0.000619 ***
BMI                 0.0073822  0.0052886   1.396 0.162796    
Motivation         -0.7433548  0.0487092 -15.261  < 2e-16 ***
Ethnicity           0.0907831  0.0696473   1.303 0.192451    
Closeness          -0.3261284  0.0356192  -9.156  < 2e-16 ***
Father              0.1006130  0.0541870   1.857 0.063379 .  
Score              -0.0527334  0.0057872  -9.112  < 2e-16 ***
Employed           -0.1545514  0.0575301  -2.686 0.007236 ** 
Illness             0.6436738  0.0585932  10.985  < 2e-16 ***
Time               -0.1003989  0.0249383  -4.026 5.73e-05 ***
Distress            0.0823413  0.0054807  15.024  < 2e-16 ***
Siblings           -0.0679471  0.0225477  -3.013 0.002591 ** 
Income             -0.0009721  0.0001731  -5.615 2.03e-08 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

(Dispersion parameter for gaussian family taken to be 3.56456)

    Null deviance: 36594  on 8242  degrees of freedom
Residual deviance: 29311  on 8223  degrees of freedom
AIC: 33892

Number of Fisher Scoring iterations: 2

2.4.1.12 Outcome: hyperactivity/inattention (model selection)

                    estimate  2.5%      97.5%     margpp   
(Intercept)        " 9.2934" " 7.2390" "10.8760" " 0.0000"
TV                 "-0.0022" " 0.0000" " 0.0000" " 0.0302"
`Electronic games` " 0.0179" " 0.0000" " 0.2303" " 0.1163"
`Social media`     " 0.0007" " 0.0000" " 0.0000" " 0.0225"
`Other internet`   "-0.0193" "-0.2312" " 0.0000" " 0.1173"
`Own computer`     "-0.0393" "-0.2077" " 0.0000" " 0.2608"
Male               " 0.8820" " 0.8010" " 0.9563" " 1.0000"
Age                "-0.1267" "-0.2339" " 0.0000" " 0.7934"
BMI                " 0.0002" " 0.0000" " 0.0037" " 0.0394"
Motivation         "-0.7527" "-0.8426" "-0.6631" " 1.0000"
Ethnicity          " 0.0086" " 0.0000" " 0.1392" " 0.0749"
Closeness          "-0.3295" "-0.3874" "-0.2723" " 1.0000"
Father             " 0.0153" " 0.0000" " 0.1489" " 0.1416"
Score              "-0.0514" "-0.0625" "-0.0407" " 1.0000"
Employed           "-0.0328" "-0.1806" " 0.0000" " 0.2359"
Illness            " 0.6539" " 0.5599" " 0.7487" " 1.0000"
Time               "-0.0932" "-0.1406" " 0.0000" " 0.9577"
Distress           " 0.0849" " 0.0749" " 0.0949" " 1.0000"
Siblings           "-0.0463" "-0.1072" " 0.0000" " 0.6529"
Income             "-0.0012" "-0.0014" "-0.0009" " 1.0000"
phi                " 3.5711" " 3.4640" " 3.6843" " 1.0000"

2.4.1.13 Outcome: peer problems (MLE)

Call:
glm(formula = y ~ ., data = datareg)

Deviance Residuals: 
    Min       1Q   Median       3Q      Max  
-3.6635  -1.0026  -0.3263   0.7258   7.5178  

Coefficients:
                     Estimate Std. Error t value Pr(>|t|)    
(Intercept)         4.3366091  0.5339199   8.122 5.24e-16 ***
TV                  0.1567142  0.0811380   1.931 0.053461 .  
`Electronic games`  0.4097196  0.0649737   6.306 3.01e-10 ***
`Social media`     -0.5627218  0.0857200  -6.565 5.53e-11 ***
`Other internet`    0.4985055  0.0863707   5.772 8.13e-09 ***
`Own computer`      0.0160416  0.0456058   0.352 0.725039    
Male               -0.0812409  0.0396950  -2.047 0.040726 *  
Age                -0.0756496  0.0358205  -2.112 0.034724 *  
BMI                 0.0405652  0.0040744   9.956  < 2e-16 ***
Motivation         -0.2051749  0.0375158  -5.469 4.66e-08 ***
Ethnicity          -0.0734334  0.0536323  -1.369 0.170974    
Closeness          -0.1734031  0.0274360  -6.320 2.75e-10 ***
Father              0.1193359  0.0417294   2.860 0.004250 ** 
Score              -0.0268602  0.0044576  -6.026 1.76e-09 ***
Employed           -0.1529954  0.0443102  -3.453 0.000558 ***
Illness             0.5915448  0.0451336  13.107  < 2e-16 ***
Time               -0.0378307  0.0192098  -1.969 0.048947 *  
Distress            0.0555466  0.0042209  13.160  < 2e-16 ***
Siblings           -0.0646996  0.0173658  -3.726 0.000196 ***
Income             -0.0006711  0.0001334  -5.033 4.94e-07 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

(Dispersion parameter for gaussian family taken to be 2.115074)

    Null deviance: 20429  on 8243  degrees of freedom
Residual deviance: 17394  on 8224  degrees of freedom
AIC: 29593

Number of Fisher Scoring iterations: 2

2.4.1.14 Outcome: peer problems (model selection)

                    estimate  2.5%      97.5%     margpp   
(Intercept)        " 3.5234" " 2.8181" " 4.9712" " 0.0000"
TV                 " 0.0309" " 0.0000" " 0.2578" " 0.1921"
`Electronic games` " 0.3698" " 0.2410" " 0.5389" " 1.0000"
`Social media`     "-0.4894" "-0.6685" "-0.3133" " 1.0000"
`Other internet`   " 0.5483" " 0.4262" " 0.6678" " 1.0000"
`Own computer`     " 0.0003" " 0.0000" " 0.0000" " 0.0313"
Male               "-0.0231" "-0.1279" " 0.0000" " 0.2582"
Age                "-0.0178" "-0.1186" " 0.0000" " 0.2286"
BMI                " 0.0411" " 0.0335" " 0.0484" " 1.0000"
Motivation         "-0.2026" "-0.2757" "-0.1313" " 1.0000"
Ethnicity          "-0.0034" "-0.0671" " 0.0000" " 0.0574"
Closeness          "-0.1794" "-0.2245" "-0.1335" " 1.0000"
Father             " 0.0632" " 0.0000" " 0.1803" " 0.5412"
Score              "-0.0273" "-0.0362" "-0.0187" " 1.0000"
Employed           "-0.0996" "-0.1816" " 0.0000" " 0.7266"
Illness            " 0.5946" " 0.5202" " 0.6698" " 1.0000"
Time               "-0.0050" "-0.0531" " 0.0000" " 0.1435"
Distress           " 0.0569" " 0.0490" " 0.0647" " 1.0000"
Siblings           "-0.0620" "-0.0980" " 0.0000" " 0.9517"
Income             "-0.0008" "-0.0010" "-0.0005" " 0.9999"
phi                " 2.1163" " 2.0526" " 2.1821" " 1.0000"

2.4.1.15 Outcome: prosocial (MLE)

Call:
glm(formula = y ~ ., data = datareg)

Deviance Residuals: 
    Min       1Q   Median       3Q      Max  
-7.8492  -0.8148   0.4089   1.0782   2.9776  

Coefficients:
                     Estimate Std. Error t value Pr(>|t|)    
(Intercept)         6.0087951  0.5540064  10.846  < 2e-16 ***
TV                  0.0653438  0.0842020   0.776 0.437750    
`Electronic games` -0.2770681  0.0674268  -4.109 4.01e-05 ***
`Social media`     -0.0171961  0.0889736  -0.193 0.846751    
`Other internet`   -0.2258844  0.0896372  -2.520 0.011755 *  
`Own computer`      0.1697692  0.0473267   3.587 0.000336 ***
Male               -0.3780747  0.0411911  -9.179  < 2e-16 ***
Age                 0.0164885  0.0371662   0.444 0.657314    
BMI                 0.0087300  0.0042279   2.065 0.038969 *  
Motivation          0.3276669  0.0389353   8.416  < 2e-16 ***
Ethnicity           0.0028792  0.0556428   0.052 0.958734    
Closeness           0.4283139  0.0284732  15.043  < 2e-16 ***
Father             -0.0354575  0.0433061  -0.819 0.412945    
Score              -0.0007898  0.0046254  -0.171 0.864416    
Employed            0.0641962  0.0459820   1.396 0.162717    
Illness            -0.1566325  0.0468371  -3.344 0.000829 ***
Time                0.0746347  0.0199374   3.743 0.000183 ***
Distress           -0.0277885  0.0043799  -6.345 2.35e-10 ***
Siblings           -0.0690299  0.0180204  -3.831 0.000129 ***
Income              0.0001286  0.0001384   0.930 0.352620    
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

(Dispersion parameter for gaussian family taken to be 2.277682)

    Null deviance: 20812  on 8242  degrees of freedom
Residual deviance: 18729  on 8223  degrees of freedom
AIC: 30200

Number of Fisher Scoring iterations: 2

2.4.1.16 Outcome: prosocial (model selection)

                    estimate    2.5%        97.5%       margpp     
(Intercept)        " 6.550221" " 6.163406" " 6.914112" " 0.000000"
TV                 " 0.000969" " 0.000000" " 0.000000" " 0.018988"
`Electronic games` "-0.287758" "-0.441727" "-0.132798" " 0.996173"
`Social media`     " 0.005065" " 0.000000" " 0.106276" " 0.051045"
`Other internet`   "-0.147087" "-0.333158" " 0.000000" " 0.670981"
`Own computer`     " 0.158953" " 0.000000" " 0.236283" " 0.906846"
Male               "-0.390665" "-0.446794" "-0.336200" " 1.000000"
Age                " 0.000216" " 0.000000" " 0.000000" " 0.016309"
BMI                " 0.000615" " 0.000000" " 0.009664" " 0.082135"
Motivation         " 0.330926" " 0.254381" " 0.407598" " 1.000000"
Ethnicity          " 0.000125" " 0.000000" " 0.000000" " 0.014152"
Closeness          " 0.426331" " 0.377100" " 0.475785" " 1.000000"
Father             "-0.001767" "-0.040237" " 0.000000" " 0.035568"
Score              " 0.000007" " 0.000000" " 0.000000" " 0.014619"
Employed           " 0.004795" " 0.000000" " 0.085379" " 0.066728"
Illness            "-0.130371" "-0.237229" " 0.000000" " 0.808017"
Time               " 0.062766" " 0.000000" " 0.105452" " 0.890376"
Distress           "-0.030240" "-0.038114" "-0.022271" " 1.000000"
Siblings           "-0.082617" "-0.113922" "-0.051036" " 0.999031"
Income             " 0.000008" " 0.000000" " 0.000169" " 0.050041"
phi                " 2.278123" " 2.209140" " 2.348884" " 1.000000"

2.4.1.17 Outcome: Happy with school work (MLE)

Call:
glm(formula = y ~ ., data = datareg)

Deviance Residuals: 
    Min       1Q   Median       3Q      Max  
-8.7308  -0.7652   0.2428   1.0642   6.7866  

Coefficients:
                     Estimate Std. Error t value Pr(>|t|)    
(Intercept)        -1.8101707  0.6156506  -2.940 0.003288 ** 
TV                  0.0838652  0.0934546   0.897 0.369537    
`Electronic games` -0.0773944  0.0747687  -1.035 0.300644    
`Social media`     -0.1100262  0.0986271  -1.116 0.264634    
`Other internet`   -0.0696145  0.0994488  -0.700 0.483945    
`Own computer`      0.0278897  0.0524357   0.532 0.594821    
Male                0.0063243  0.0456586   0.139 0.889839    
Age                 0.0772994  0.0412894   1.872 0.061222 .  
BMI                -0.0086826  0.0046895  -1.851 0.064133 .  
Motivation          2.0810588  0.0432326  48.136  < 2e-16 ***
Ethnicity           0.2087800  0.0617285   3.382 0.000722 ***
Closeness           0.3703807  0.0315761  11.730  < 2e-16 ***
Father             -0.0721176  0.0480355  -1.501 0.133305    
Score               0.0067405  0.0051232   1.316 0.188322    
Employed            0.0328135  0.0510232   0.643 0.520172    
Illness            -0.2143114  0.0519297  -4.127 3.71e-05 ***
Time                0.0238612  0.0221028   1.080 0.280373    
Distress           -0.0084978  0.0048663  -1.746 0.080802 .  
Siblings            0.0250836  0.0199564   1.257 0.208817    
Income              0.0004788  0.0001527   3.135 0.001726 ** 
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

(Dispersion parameter for gaussian family taken to be 2.854453)

    Null deviance: 35326  on 8410  degrees of freedom
Residual deviance: 23952  on 8391  degrees of freedom
AIC: 32713

Number of Fisher Scoring iterations: 2

2.4.1.18 Outcome: Happy with school work (model selection)

                    estimate   2.5%       97.5%      margpp    
(Intercept)        "-0.95948" "-1.33356" "-0.61992" " 0.00000"
TV                 " 0.00005" " 0.00000" " 0.00000" " 0.00515"
`Electronic games` "-0.00061" " 0.00000" " 0.00000" " 0.01046"
`Social media`     "-0.00031" " 0.00000" " 0.00000" " 0.00704"
`Other internet`   "-0.00006" " 0.00000" " 0.00000" " 0.00540"
`Own computer`     " 0.00010" " 0.00000" " 0.00000" " 0.00545"
Male               "-0.00004" " 0.00000" " 0.00000" " 0.00521"
Age                " 0.00115" " 0.00000" " 0.00000" " 0.02017"
BMI                "-0.00033" "-0.00748" " 0.00000" " 0.03831"
Motivation         " 2.09642" " 2.02342" " 2.16954" " 1.00000"
Ethnicity          " 0.09736" " 0.00000" " 0.23481" " 0.51099"
Closeness          " 0.37621" " 0.32871" " 0.42349" " 1.00000"
Father             "-0.00180" " 0.00000" " 0.00000" " 0.02275"
Score              " 0.00024" " 0.00000" " 0.00013" " 0.02819"
Employed           " 0.00012" " 0.00000" " 0.00000" " 0.00592"
Illness            "-0.21798" "-0.30006" "-0.12026" " 0.97636"
Time               " 0.00013" " 0.00000" " 0.00000" " 0.00822"
Distress           "-0.00050" "-0.01029" " 0.00000" " 0.05239"
Siblings           " 0.00057" " 0.00000" " 0.00000" " 0.01877"
Income             " 0.00073" " 0.00054" " 0.00093" " 0.99995"
phi                " 2.85903" " 2.77262" " 2.94577" " 1.00000"

2.4.1.19 Outcome: Happy with looks (MLE)

Call:
glm(formula = y ~ ., data = datareg)

Deviance Residuals: 
    Min       1Q   Median       3Q      Max  
-7.9356  -1.2423   0.2036   1.3933   8.0702  

Coefficients:
                     Estimate Std. Error t value Pr(>|t|)    
(Intercept)         1.8596857  0.7304999   2.546  0.01092 *  
TV                 -0.0634174  0.1109198  -0.572  0.56751    
`Electronic games` -0.0212234  0.0887395  -0.239  0.81098    
`Social media`     -0.3520340  0.1170241  -3.008  0.00264 ** 
`Other internet`   -0.5494324  0.1179882  -4.657 3.26e-06 ***
`Own computer`      0.0670740  0.0621644   1.079  0.28063    
Male                1.1312215  0.0541586  20.887  < 2e-16 ***
Age                -0.0074249  0.0489806  -0.152  0.87951    
BMI                -0.0758097  0.0055584 -13.639  < 2e-16 ***
Motivation          1.3273534  0.0513116  25.868  < 2e-16 ***
Ethnicity          -0.0236308  0.0731580  -0.323  0.74670    
Closeness           0.5863756  0.0374431  15.660  < 2e-16 ***
Father              0.0273405  0.0569652   0.480  0.63127    
Score              -0.0190592  0.0060764  -3.137  0.00172 ** 
Employed            0.0030156  0.0605348   0.050  0.96027    
Illness            -0.2892058  0.0616499  -4.691 2.76e-06 ***
Time                0.0793201  0.0262171   3.026  0.00249 ** 
Distress           -0.0043809  0.0057709  -0.759  0.44779    
Siblings            0.0432715  0.0236566   1.829  0.06741 .  
Income              0.0001836  0.0001812   1.014  0.31079    
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

(Dispersion parameter for gaussian family taken to be 4.009386)

    Null deviance: 45236  on 8400  degrees of freedom
Residual deviance: 33603  on 8381  degrees of freedom
AIC: 35529

Number of Fisher Scoring iterations: 2

2.4.1.20 Outcome: Happy with looks (model selection)

                    estimate     2.5%         97.5%        margpp      
(Intercept)        " 1.9207116" " 1.2621748" " 2.4578833" " 0.0000000"
TV                 "-0.0018974" " 0.0000000" " 0.0000000" " 0.0180890"
`Electronic games` "-0.0005701" " 0.0000000" " 0.0000000" " 0.0134366"
`Social media`     "-0.3493896" "-0.6020870" " 0.0000000" " 0.8849824"
`Other internet`   "-0.5523669" "-0.7309320" "-0.2604455" " 0.9909879"
`Own computer`     " 0.0006554" " 0.0000000" " 0.0000000" " 0.0156269"
Male               " 1.1238068" " 1.0596333" " 1.1881631" " 1.0000000"
Age                "-0.0000174" " 0.0000000" " 0.0000000" " 0.0108956"
BMI                "-0.0767459" "-0.0861854" "-0.0672885" " 1.0000000"
Motivation         " 1.3405335" " 1.2480630" " 1.4358221" " 1.0000000"
Ethnicity          "-0.0005224" " 0.0000000" " 0.0000000" " 0.0159560"
Closeness          " 0.5912345" " 0.5318601" " 0.6508484" " 1.0000000"
Father             "-0.0000623" " 0.0000000" " 0.0000000" " 0.0113731"
Score              "-0.0144874" "-0.0271385" " 0.0000000" " 0.7820306"
Employed           "-0.0001240" " 0.0000000" " 0.0000000" " 0.0117777"
Illness            "-0.3011110" "-0.3966136" "-0.2062078" " 0.9993884"
Time               " 0.0507243" " 0.0000000" " 0.1210340" " 0.6160025"
Distress           "-0.0000780" " 0.0000000" " 0.0000000" " 0.0170476"
Siblings           " 0.0015066" " 0.0000000" " 0.0314176" " 0.0440809"
Income             " 0.0000004" " 0.0000000" " 0.0000000" " 0.0142157"
phi                " 4.0078381" " 3.8874313" " 4.1306972" " 1.0000000"

2.4.1.21 Outcome: Happy with family (MLE)

Call:
glm(formula = y ~ ., data = datareg)

Deviance Residuals: 
    Min       1Q   Median       3Q      Max  
-9.4138  -0.5798   0.3414   1.0640   5.5511  

Coefficients:
                     Estimate Std. Error t value Pr(>|t|)    
(Intercept)         1.9437250  0.6394887   3.039 0.002377 ** 
TV                  0.1796089  0.0971225   1.849 0.064449 .  
`Electronic games`  0.0564833  0.0776860   0.727 0.467202    
`Social media`     -0.1587681  0.1024700  -1.549 0.121321    
`Other internet`   -0.0756555  0.1033750  -0.732 0.464278    
`Own computer`      0.0764054  0.0545174   1.401 0.161106    
Male                0.0782979  0.0474293   1.651 0.098810 .  
Age                 0.0612251  0.0428880   1.428 0.153456    
BMI                -0.0165419  0.0048676  -3.398 0.000681 ***
Motivation          0.7306965  0.0449299  16.263  < 2e-16 ***
Ethnicity           0.4511916  0.0641291   7.036 2.14e-12 ***
Closeness           1.1605692  0.0328038  35.379  < 2e-16 ***
Father             -0.2849766  0.0499192  -5.709 1.18e-08 ***
Score              -0.0205246  0.0053224  -3.856 0.000116 ***
Employed           -0.0332280  0.0529836  -0.627 0.530586    
Illness            -0.1371602  0.0539474  -2.542 0.011025 *  
Time                0.0347576  0.0229507   1.514 0.129951    
Distress           -0.0146109  0.0050608  -2.887 0.003898 ** 
Siblings            0.0056904  0.0207194   0.275 0.783599    
Income              0.0001886  0.0001587   1.188 0.234741    
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

(Dispersion parameter for gaussian family taken to be 3.076101)

    Null deviance: 34113  on 8402  degrees of freedom
Residual deviance: 25787  on 8383  degrees of freedom
AIC: 33311

Number of Fisher Scoring iterations: 2

2.4.1.22 Outcome: Happy with family (model selection)

                    estimate    2.5%        97.5%       margpp     
(Intercept)        " 2.882995" " 2.290740" " 3.338846" " 0.000000"
TV                 " 0.001953" " 0.000000" " 0.000000" " 0.021627"
`Electronic games` " 0.005411" " 0.000000" " 0.116648" " 0.044682"
`Social media`     "-0.001770" " 0.000000" " 0.000000" " 0.020867"
`Other internet`   " 0.000731" " 0.000000" " 0.000000" " 0.012510"
`Own computer`     " 0.001377" " 0.000000" " 0.000000" " 0.021424"
Male               " 0.022749" " 0.000000" " 0.148359" " 0.223313"
Age                " 0.000794" " 0.000000" " 0.000000" " 0.019512"
BMI                "-0.015280" "-0.025874" " 0.000000" " 0.847072"
Motivation         " 0.751999" " 0.670458" " 0.834496" " 1.000000"
Ethnicity          " 0.445737" " 0.339136" " 0.547402" " 1.000000"
Closeness          " 1.172430" " 1.119749" " 1.224897" " 1.000000"
Father             "-0.321610" "-0.355823" "-0.285109" " 1.000000"
Score              "-0.017469" "-0.026953" " 0.000000" " 0.918416"
Employed           "-0.000075" " 0.000000" " 0.000000" " 0.009004"
Illness            "-0.022015" "-0.183199" " 0.000000" " 0.170232"
Time               " 0.001327" " 0.000000" " 0.027570" " 0.036175"
Distress           "-0.010248" "-0.023697" " 0.000000" " 0.627824"
Siblings           "-0.000049" " 0.000000" " 0.000000" " 0.008580"
Income             " 0.000002" " 0.000000" " 0.000000" " 0.017609"
phi                " 3.081118" " 2.990265" " 3.177711" " 1.000000"

2.4.1.23 Outcome: Happy with friends (MLE)

Call:
glm(formula = y ~ ., data = datareg)

Deviance Residuals: 
    Min       1Q   Median       3Q      Max  
-8.9091  -0.5990   0.3865   1.1950   3.6654  

Coefficients:
                     Estimate Std. Error t value Pr(>|t|)    
(Intercept)         3.560e+00  6.669e-01   5.338 9.65e-08 ***
TV                  7.483e-02  1.012e-01   0.739 0.459722    
`Electronic games`  6.305e-03  8.100e-02   0.078 0.937958    
`Social media`      1.866e-01  1.069e-01   1.745 0.080947 .  
`Other internet`   -1.195e-01  1.078e-01  -1.108 0.267679    
`Own computer`      4.736e-03  5.679e-02   0.083 0.933533    
Male                1.768e-01  4.945e-02   3.575 0.000353 ***
Age                 3.173e-02  4.472e-02   0.709 0.478070    
BMI                -5.801e-03  5.078e-03  -1.142 0.253353    
Motivation          8.337e-01  4.680e-02  17.812  < 2e-16 ***
Ethnicity           2.084e-01  6.681e-02   3.120 0.001817 ** 
Closeness           5.317e-01  3.419e-02  15.552  < 2e-16 ***
Father             -4.777e-02  5.201e-02  -0.918 0.358430    
Score              -1.740e-02  5.547e-03  -3.137 0.001712 ** 
Employed            1.636e-02  5.527e-02   0.296 0.767255    
Illness            -3.072e-01  5.627e-02  -5.459 4.93e-08 ***
Time                8.357e-03  2.392e-02   0.349 0.726869    
Distress           -1.087e-02  5.273e-03  -2.062 0.039251 *  
Siblings            4.381e-03  2.160e-02   0.203 0.839302    
Income              8.315e-05  1.654e-04   0.503 0.615201    
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

(Dispersion parameter for gaussian family taken to be 3.345175)

    Null deviance: 31579  on 8407  degrees of freedom
Residual deviance: 28059  on 8388  degrees of freedom
AIC: 34036

Number of Fisher Scoring iterations: 2

2.4.1.24 Outcome: Happy with friends (model selection)

                    estimate     2.5%         97.5%        margpp      
(Intercept)        " 3.7828795" " 3.3840464" " 4.2496682" " 0.0000000"
TV                 " 0.0005787" " 0.0000000" " 0.0000000" " 0.0082524"
`Electronic games` " 0.0004113" " 0.0000000" " 0.0000000" " 0.0085614"
`Social media`     " 0.2538057" " 0.0000000" " 0.4478912" " 0.8312385"
`Other internet`   "-0.0263908" "-0.3213860" " 0.0000000" " 0.1018174"
`Own computer`     " 0.0000420" " 0.0000000" " 0.0000000" " 0.0060804"
Male               " 0.1752343" " 0.0000000" " 0.2475606" " 0.9621348"
Age                " 0.0002306" " 0.0000000" " 0.0000000" " 0.0074593"
BMI                "-0.0000472" " 0.0000000" " 0.0000000" " 0.0106929"
Motivation         " 0.8382053" " 0.7443873" " 0.9314048" " 1.0000000"
Ethnicity          " 0.0217483" " 0.0000000" " 0.1995538" " 0.1359737"
Closeness          " 0.5404983" " 0.4836608" " 0.5969960" " 1.0000000"
Father             "-0.0004758" " 0.0000000" " 0.0000000" " 0.0103286"
Score              "-0.0007620" "-0.0136167" " 0.0000000" " 0.0715507"
Employed           " 0.0002233" " 0.0000000" " 0.0000000" " 0.0077226"
Illness            "-0.3214507" "-0.4179439" "-0.2250430" " 0.9999840"
Time               " 0.0000579" " 0.0000000" " 0.0000000" " 0.0066482"
Distress           "-0.0007621" "-0.0128520" " 0.0000000" " 0.0736436"
Siblings           " 0.0000014" " 0.0000000" " 0.0000000" " 0.0059082"
Income             " 0.0000008" " 0.0000000" " 0.0000000" " 0.0084319"
phi                " 3.3484518" " 3.2489607" " 3.4512653" " 1.0000000"

2.4.1.25 Outcome: Happy with school (MLE)

Call:
glm(formula = y ~ ., data = datareg)

Deviance Residuals: 
    Min       1Q   Median       3Q      Max  
-8.9405  -0.9292   0.3083   1.2627   6.7346  

Coefficients:
                     Estimate Std. Error t value Pr(>|t|)    
(Intercept)        -1.6143388  0.7032068  -2.296 0.021719 *  
TV                 -0.0639304  0.1068597  -0.598 0.549679    
`Electronic games` -0.1173131  0.0854512  -1.373 0.169830    
`Social media`     -0.0132519  0.1127608  -0.118 0.906449    
`Other internet`    0.0312327  0.1136831   0.275 0.783527    
`Own computer`      0.0978417  0.0598951   1.634 0.102391    
Male                0.1456206  0.0521300   2.793 0.005227 ** 
Age                 0.0974612  0.0471429   2.067 0.038731 *  
BMI                -0.0150613  0.0053527  -2.814 0.004908 ** 
Motivation          1.9680129  0.0494110  39.829  < 2e-16 ***
Ethnicity           0.1299202  0.0704380   1.844 0.065151 .  
Closeness           0.3878838  0.0360353  10.764  < 2e-16 ***
Father             -0.0548240  0.0548412  -1.000 0.317490    
Score               0.0213428  0.0058484   3.649 0.000264 ***
Employed            0.0251073  0.0582387   0.431 0.666400    
Illness            -0.2703390  0.0593008  -4.559 5.22e-06 ***
Time                0.0238453  0.0252429   0.945 0.344873    
Distress           -0.0103628  0.0055569  -1.865 0.062239 .  
Siblings            0.0363812  0.0227854   1.597 0.110372    
Income              0.0005852  0.0001744   3.355 0.000798 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

(Dispersion parameter for gaussian family taken to be 3.719091)

    Null deviance: 42169  on 8406  degrees of freedom
Residual deviance: 31192  on 8387  degrees of freedom
AIC: 34922

Number of Fisher Scoring iterations: 2

2.4.1.26 Outcome: Happy with school (model selection)

                    estimate  2.5%      97.5%     margpp   
(Intercept)        "-0.4407" "-1.5597" " 0.1487" " 0.0000"
TV                 "-0.0013" " 0.0000" " 0.0000" " 0.0137"
`Electronic games` "-0.0006" " 0.0000" " 0.0000" " 0.0113"
`Social media`     "-0.0010" " 0.0000" " 0.0000" " 0.0123"
`Other internet`   " 0.0003" " 0.0000" " 0.0000" " 0.0079"
`Own computer`     " 0.0013" " 0.0000" " 0.0000" " 0.0181"
Male               " 0.0324" " 0.0000" " 0.1636" " 0.2717"
Age                " 0.0041" " 0.0000" " 0.0897" " 0.0480"
BMI                "-0.0086" "-0.0247" " 0.0000" " 0.4985"
Motivation         " 1.9830" " 1.8958" " 2.0684" " 1.0000"
Ethnicity          " 0.0017" " 0.0000" " 0.0000" " 0.0208"
Closeness          " 0.4033" " 0.3461" " 0.4600" " 1.0000"
Father             "-0.0008" " 0.0000" " 0.0000" " 0.0147"
Score              " 0.0234" " 0.0093" " 0.0343" " 0.9767"
Employed           " 0.0001" " 0.0000" " 0.0000" " 0.0071"
Illness            "-0.2808" "-0.3724" "-0.1881" " 0.9979"
Time               " 0.0002" " 0.0000" " 0.0000" " 0.0102"
Distress           "-0.0007" "-0.0125" " 0.0000" " 0.0677"
Siblings           " 0.0010" " 0.0000" " 0.0000" " 0.0275"
Income             " 0.0007" " 0.0005" " 0.0010" " 0.9992"
phi                " 3.7249" " 3.6144" " 3.8398" " 1.0000"

2.4.1.27 Outcome: Happy with life (MLE)

Call:
glm(formula = y ~ ., data = datareg)

Deviance Residuals: 
    Min       1Q   Median       3Q      Max  
-9.2672  -0.8334   0.2747   1.1648   5.3218  

Coefficients:
                     Estimate Std. Error t value Pr(>|t|)    
(Intercept)         7.127e-01  6.537e-01   1.090 0.275573    
TV                 -1.881e-02  9.925e-02  -0.189 0.849710    
`Electronic games` -5.254e-02  7.944e-02  -0.661 0.508389    
`Social media`     -2.305e-01  1.049e-01  -2.199 0.027938 *  
`Other internet`   -3.624e-01  1.057e-01  -3.429 0.000609 ***
`Own computer`      5.884e-02  5.566e-02   1.057 0.290498    
Male                5.727e-01  4.847e-02  11.816  < 2e-16 ***
Age                 4.426e-02  4.382e-02   1.010 0.312435    
BMI                -2.817e-02  4.980e-03  -5.655 1.61e-08 ***
Motivation          1.381e+00  4.594e-02  30.069  < 2e-16 ***
Ethnicity           3.810e-01  6.548e-02   5.819 6.12e-09 ***
Closeness           7.897e-01  3.353e-02  23.554  < 2e-16 ***
Father             -1.461e-01  5.098e-02  -2.866 0.004172 ** 
Score              -1.766e-02  5.437e-03  -3.248 0.001165 ** 
Employed            6.529e-02  5.414e-02   1.206 0.227909    
Illness            -3.845e-01  5.519e-02  -6.967 3.49e-12 ***
Time                2.677e-02  2.346e-02   1.141 0.253768    
Distress           -2.013e-02  5.167e-03  -3.896 9.84e-05 ***
Siblings            3.674e-02  2.117e-02   1.735 0.082747 .  
Income              1.521e-05  1.621e-04   0.094 0.925268    
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

(Dispersion parameter for gaussian family taken to be 3.210124)

    Null deviance: 37208  on 8396  degrees of freedom
Residual deviance: 26891  on 8377  degrees of freedom
AIC: 33645

Number of Fisher Scoring iterations: 2

2.4.1.28 Outcome: Happy with life (model selection)

                    estimate     2.5%         97.5%        margpp      
(Intercept)        " 1.3251698" " 0.7721545" " 1.8113409" " 0.0000000"
TV                 "-0.0025670" " 0.0000000" " 0.0000000" " 0.0265688"
`Electronic games` "-0.0043840" "-0.0822660" " 0.0000000" " 0.0442652"
`Social media`     "-0.0431420" "-0.3508461" " 0.0000000" " 0.1873607"
`Other internet`   "-0.1671176" "-0.4751776" " 0.0000000" " 0.6043934"
`Own computer`     " 0.0004580" " 0.0000000" " 0.0000000" " 0.0175126"
Male               " 0.5579964" " 0.4833562" " 0.6319773" " 1.0000000"
Age                " 0.0008615" " 0.0000000" " 0.0000000" " 0.0223867"
BMI                "-0.0289470" "-0.0373683" "-0.0203526" " 0.9999954"
Motivation         " 1.4043113" " 1.3211134" " 1.4847707" " 1.0000000"
Ethnicity          " 0.3512281" " 0.2442438" " 0.4585703" " 0.9997626"
Closeness          " 0.7951415" " 0.7424511" " 0.8481118" " 1.0000000"
Father             "-0.1394889" "-0.2099877" " 0.0000000" " 0.8425092"
Score              "-0.0146901" "-0.0253223" " 0.0000000" " 0.8301333"
Employed           " 0.0003992" " 0.0000000" " 0.0000000" " 0.0178760"
Illness            "-0.3922079" "-0.4758226" "-0.3061978" " 1.0000000"
Time               " 0.0005626" " 0.0000000" " 0.0000000" " 0.0235253"
Distress           "-0.0217739" "-0.0301566" "-0.0131680" " 0.9910417"
Siblings           " 0.0015906" " 0.0000000" " 0.0316199" " 0.0522126"
Income             " 0.0000001" " 0.0000000" " 0.0000000" " 0.0178309"
phi                " 3.2111543" " 3.1141466" " 3.3113423" " 1.0000000"

2.4.2 BSCA Layout

Only show 50 models and decrease the size of the legend to nicely combine in the grid figure.

maxmodels = 50
legend_size = 1

2.4.3 Main BSCAs

bsca_main_lin = list()
for (y_name in names(y_main)) {
  cat('\n    \n')
  cat("#### ", 'Outcome: ', y_name, '\n')
  single_bsca(
    mcs_ms[[y_name]], coefidx=idx+1, maxmodels=maxmodels,
    x.labels=x_names, var.labels=names(cvars), 
    legend.cex=legend_size
  )
  bsca_main_lin[[y_name]] = recordPlot()
}

2.4.3.1 Outcome: Depression (adolescent)

2.4.3.2 Outcome: Self-esteem (adolescent)

2.4.3.3 Outcome: Total difficulties (parent)

2.4.3.4 Outcome: Emotional problems (parent)

2.4.3.5 Combined plot

supplement$bsca_main_lin = plot_grid(plotlist=bsca_main_lin, ncol=2, labels='auto')
ggsave(
  file.path(plot_path, 'mcs_bsca_main_lin.png'), 
  supplement$bsca_main_lin,
  height=6, width=8
)
supplement$bsca_main_lin

2.4.4 Parent BSCAs

bsca_parent_lin = list()
for (y_name in names(y_pm)) {
  cat('\n    \n')
  cat("#### ", 'Outcome: ', y_name, '\n')
  single_bsca(
    mcs_ms[[y_name]], coefidx=idx+1, maxmodels=maxmodels,
    x.labels=x_names, var.labels=names(cvars), 
    legend.cex=legend_size
  )
  bsca_parent_lin[[y_name]] = recordPlot()
}

2.4.4.1 Outcome: conduct problems

2.4.4.2 Outcome: hyperactivity/inattention

2.4.4.3 Outcome: peer problems

2.4.4.4 Outcome: prosocial

2.4.4.5 Combined plot

supplement$bsca_parent_lin = plot_grid(plotlist=bsca_parent_lin, ncol=2, labels='auto')
ggsave(
  file.path(plot_path, 'mcs_bsca_parent_lin.png'), 
  supplement$bsca_parent_lin,
  height=6, width=8
)
supplement$bsca_parent_lin

2.4.5 Adolescent BSCAs

bsca_teen_lin = list()
for (y_name in names(y_cm)) {
  cat('\n    \n')
  cat("#### ", 'Outcome: ', y_name, '\n')
  single_bsca(
    mcs_ms[[y_name]], coefidx=idx+1, maxmodels=maxmodels,
    x.labels=x_names, var.labels=names(cvars),
    legend.cex=legend_size
  )
  bsca_teen_lin[[y_name]] = recordPlot()
}

2.4.5.1 Outcome: Happy with school work

2.4.5.2 Outcome: Happy with looks

2.4.5.3 Outcome: Happy with family

2.4.5.4 Outcome: Happy with friends

2.4.5.5 Outcome: Happy with school

2.4.5.6 Outcome: Happy with life

2.4.5.7 Combined plot

supplement$bsca_teen_lin = plot_grid(plotlist=bsca_teen_lin, ncol=2, labels='auto')
ggsave(
  file.path(plot_path, 'mcs_bsca_teen_lin.png'), 
  supplement$bsca_teen_lin,
  height=9, width=8
)
supplement$bsca_teen_lin

2.5 LOGIT ANALYSIS

2.5.1 Regressions

For computational efficiency, we perform the logistic regression BMA on the top 100 linear models for each outcome.

# assumes outcome variables have the same order in mcs_ms and yvars
pp_lin = lapply(mcs_ms[seq_along(yvars)], postProb)

b = list(); ms_logit = list()
for (idy in 1:length(yvars)) {
  yvar = yvars[idy]; yname = names(yvars)[idy]
  print(yname)  
  
  datareg = na.omit(data[c(yvar, x_vars, cvars)])
  names(datareg) = c('y', x_names, names(cvars))
  reg = y ~ .
  
  # MLE
  fit1 = glm(reg, data=datareg, family=binomial(link='logit'))
  print(summary(fit1))
  
  # BMA
  models = as.matrix.pp(pp_lin[[idy]], nummodels=100, numvars=length(datareg))
  ms_logit[[yname]] = mombf:::modelSelectionGLM(reg, data=datareg, familyglm= binomial(link='logit'), priorDelta=modelbbprior(1,1), models=models)
  b[[yname]] = coef(ms_logit[[yname]])
  cat('\n')
  print(format(as.data.frame(coef(ms_logit[[yname]])), digits=1, scientific=FALSE))
}
## [1] "Depressed (adolescent)"
## 
## Call:
## glm(formula = reg, family = binomial(link = "logit"), data = datareg)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -2.0966  -0.5178  -0.3256  -0.1860   3.0300  
## 
## Coefficients:
##                      Estimate Std. Error z value Pr(>|z|)    
## (Intercept)         2.9123597  1.1982691   2.430   0.0151 *  
## TV                 -0.1384186  0.1733528  -0.798   0.4246    
## `Electronic games`  0.2881925  0.1345923   2.141   0.0323 *  
## `Social media`      1.0019289  0.1956082   5.122 3.02e-07 ***
## `Other internet`    0.9774131  0.2015802   4.849 1.24e-06 ***
## `Own computer`     -0.1221798  0.1003742  -1.217   0.2235    
## Male               -1.2057271  0.0916487 -13.156  < 2e-16 ***
## Age                 0.0924750  0.0810438   1.141   0.2538    
## BMI                 0.0446528  0.0085369   5.231 1.69e-07 ***
## Motivation         -1.6155323  0.0807056 -20.018  < 2e-16 ***
## Ethnicity          -0.2387360  0.1215431  -1.964   0.0495 *  
## Closeness          -0.7776110  0.0575084 -13.522  < 2e-16 ***
## Father              0.0580899  0.0884572   0.657   0.5114    
## Score               0.0254251  0.0099399   2.558   0.0105 *  
## Employed           -0.0117341  0.0979694  -0.120   0.9047    
## Illness             0.4944752  0.0906233   5.456 4.86e-08 ***
## Time               -0.0098791  0.0418903  -0.236   0.8136    
## Distress            0.0205760  0.0088260   2.331   0.0197 *  
## Siblings           -0.0688479  0.0381972  -1.802   0.0715 .  
## Income              0.0004037  0.0002935   1.375   0.1690    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for binomial family taken to be 1)
## 
##     Null deviance: 6928.1  on 8350  degrees of freedom
## Residual deviance: 5324.5  on 8331  degrees of freedom
## AIC: 5364.5
## 
## Number of Fisher Scoring iterations: 6
## 
## Enumerating 100 models..........
##                    estimate  2.5%   97.5% margpp
## (Intercept)         4.10295  3.22  4.9743  1.000
## TV                 -0.00088  0.00  0.0000  0.009
## `Electronic games`  0.00406  0.00  0.0000  0.020
## `Social media`      0.99953  0.64  1.3531  1.000
## `Other internet`    1.04151  0.67  1.4112  1.000
## `Own computer`     -0.00055  0.00  0.0000  0.007
## Male               -1.11318 -1.27 -0.9539  1.000
## Age                 0.00139  0.00  0.0000  0.014
## BMI                 0.04467  0.03  0.0610  1.000
## Motivation         -1.60712 -1.76 -1.4507  1.000
## Ethnicity          -0.00296  0.00  0.0000  0.015
## Closeness          -0.78352 -0.90 -0.6685  1.000
## Father              0.00006  0.00  0.0000  0.008
## Score               0.01334  0.00  0.0407  0.500
## Employed            0.00026  0.00  0.0000  0.005
## Illness             0.51185  0.34  0.6854  1.000
## Time               -0.00009  0.00  0.0000  0.008
## Distress            0.00219  0.00  0.0261  0.109
## Siblings           -0.00882 -0.11  0.0000  0.112
## Income              0.00005  0.00  0.0007  0.089
## [1] "Low self-esteem (adolescent)"
## 
## Call:
## glm(formula = reg, family = binomial(link = "logit"), data = datareg)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -2.1532  -0.4507  -0.2805  -0.1668   3.4254  
## 
## Coefficients:
##                      Estimate Std. Error z value Pr(>|z|)    
## (Intercept)         4.753e+00  1.311e+00   3.625 0.000289 ***
## TV                 -1.960e-01  1.909e-01  -1.027 0.304546    
## `Electronic games` -4.807e-02  1.484e-01  -0.324 0.746048    
## `Social media`      8.081e-01  2.187e-01   3.695 0.000220 ***
## `Other internet`    1.384e+00  2.237e-01   6.189 6.05e-10 ***
## `Own computer`     -1.596e-01  1.108e-01  -1.440 0.149938    
## Male               -1.356e+00  1.053e-01 -12.883  < 2e-16 ***
## Age                -4.303e-02  8.845e-02  -0.486 0.626658    
## BMI                 5.697e-02  9.270e-03   6.145 7.97e-10 ***
## Motivation         -1.728e+00  8.866e-02 -19.489  < 2e-16 ***
## Ethnicity           3.796e-02  1.397e-01   0.272 0.785910    
## Closeness          -6.534e-01  6.279e-02 -10.405  < 2e-16 ***
## Father             -3.048e-02  9.811e-02  -0.311 0.756030    
## Score               1.783e-02  1.109e-02   1.608 0.107944    
## Employed           -1.019e-01  1.080e-01  -0.944 0.345334    
## Illness             4.541e-01  9.989e-02   4.546 5.48e-06 ***
## Time               -6.444e-02  4.648e-02  -1.386 0.165643    
## Distress           -3.396e-03  9.964e-03  -0.341 0.733267    
## Siblings           -5.317e-02  4.235e-02  -1.256 0.209278    
## Income              2.796e-05  3.288e-04   0.085 0.932244    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for binomial family taken to be 1)
## 
##     Null deviance: 5796.4  on 8310  degrees of freedom
## Residual deviance: 4447.6  on 8291  degrees of freedom
## AIC: 4487.6
## 
## Number of Fisher Scoring iterations: 6
## 
## Enumerating 100 models..........
##                     estimate  2.5% 97.5% margpp
## (Intercept)         4.178736  3.26  5.11  1.000
## TV                 -0.000005  0.00  0.00  0.002
## `Electronic games` -0.000113  0.00  0.00  0.003
## `Social media`      0.398357  0.00  1.00  0.603
## `Other internet`    1.113359  0.59  1.67  1.000
## `Own computer`     -0.000349  0.00  0.00  0.003
## Male               -1.385668 -1.57 -1.20  1.000
## Age                -0.000064  0.00  0.00  0.002
## BMI                 0.054517  0.04  0.07  1.000
## Motivation         -1.751640 -1.93 -1.57  1.000
## Ethnicity           0.001796  0.00  0.00  0.013
## Closeness          -0.661873 -0.78 -0.54  1.000
## Father             -0.000137  0.00  0.00  0.008
## Score               0.000391  0.00  0.00  0.019
## Employed            0.000076  0.00  0.00  0.002
## Illness             0.465530  0.27  0.66  1.000
## Time               -0.001533  0.00  0.00  0.022
## Distress           -0.000007  0.00  0.00  0.003
## Siblings           -0.000453  0.00  0.00  0.008
## Income              0.000001  0.00  0.00  0.005
## [1] "High total difficulties (parent)"
## 
## Call:
## glm(formula = reg, family = binomial(link = "logit"), data = datareg)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -2.2519  -0.5226  -0.3600  -0.2427   2.9810  
## 
## Coefficients:
##                      Estimate Std. Error z value Pr(>|z|)    
## (Intercept)         3.6102077  1.1493635   3.141 0.001683 ** 
## TV                 -0.2906432  0.1699675  -1.710 0.087267 .  
## `Electronic games`  0.5721780  0.1374293   4.163 3.13e-05 ***
## `Social media`     -0.6672431  0.1837169  -3.632 0.000281 ***
## `Other internet`   -0.0594801  0.1837279  -0.324 0.746135    
## `Own computer`     -0.0005930  0.0975966  -0.006 0.995152    
## Male                0.0407176  0.0865947   0.470 0.638205    
## Age                -0.1065596  0.0778601  -1.369 0.171123    
## BMI                 0.0445012  0.0080482   5.529 3.21e-08 ***
## Motivation         -0.7899637  0.0766313 -10.309  < 2e-16 ***
## Ethnicity          -0.0331434  0.1120474  -0.296 0.767384    
## Closeness          -0.5358819  0.0572741  -9.356  < 2e-16 ***
## Father              0.1908087  0.0839471   2.273 0.023028 *  
## Score              -0.0587983  0.0098837  -5.949 2.70e-09 ***
## Employed           -0.1834213  0.0895539  -2.048 0.040544 *  
## Illness             1.0365071  0.0814076  12.732  < 2e-16 ***
## Time               -0.0981691  0.0405462  -2.421 0.015471 *  
## Distress            0.1092434  0.0078413  13.932  < 2e-16 ***
## Siblings           -0.0460048  0.0360954  -1.275 0.202474    
## Income             -0.0011508  0.0003099  -3.713 0.000205 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for binomial family taken to be 1)
## 
##     Null deviance: 6631.0  on 8237  degrees of freedom
## Residual deviance: 5447.7  on 8218  degrees of freedom
## AIC: 5487.7
## 
## Number of Fisher Scoring iterations: 5
## 
## Enumerating 100 models..........
##                    estimate   2.5%   97.5% margpp
## (Intercept)         1.89736  1.018  2.8265  1.000
## TV                 -0.00486  0.000  0.0000  0.017
## `Electronic games`  0.57307  0.350  0.7950  1.000
## `Social media`     -0.71687 -0.957 -0.4739  1.000
## `Other internet`   -0.00036  0.000  0.0000  0.004
## `Own computer`     -0.00011  0.000  0.0000  0.003
## Male                0.00016  0.000  0.0000  0.005
## Age                -0.00280 -0.004  0.0000  0.027
## BMI                 0.04261  0.027  0.0583  1.000
## Motivation         -0.79070 -0.939 -0.6405  1.000
## Ethnicity           0.00004  0.000  0.0000  0.003
## Closeness          -0.53704 -0.649 -0.4268  1.000
## Father              0.04828  0.000  0.3056  0.243
## Score              -0.05543 -0.075 -0.0368  1.000
## Employed           -0.00391 -0.041  0.0000  0.032
## Illness             1.03596  0.879  1.1936  1.000
## Time               -0.01108 -0.122  0.0000  0.128
## Distress            0.11263  0.097  0.1275  1.000
## Siblings           -0.00162 -0.030  0.0000  0.030
## Income             -0.00140 -0.002 -0.0008  1.000
## [1] "High emotional problems (parent)"
## 
## Call:
## glm(formula = reg, family = binomial(link = "logit"), data = datareg)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -2.2257  -0.6307  -0.4763  -0.3392   2.5813  
## 
## Coefficients:
##                      Estimate Std. Error z value Pr(>|z|)    
## (Intercept)        -0.2467202  1.0078666  -0.245 0.806616    
## TV                  0.1095932  0.1505266   0.728 0.466574    
## `Electronic games`  0.1844561  0.1195515   1.543 0.122855    
## `Social media`     -0.4752359  0.1608935  -2.954 0.003140 ** 
## `Other internet`    0.1685465  0.1620166   1.040 0.298199    
## `Own computer`      0.1012856  0.0875318   1.157 0.247219    
## Male               -0.7182505  0.0758118  -9.474  < 2e-16 ***
## Age                 0.0704137  0.0681666   1.033 0.301620    
## BMI                 0.0194037  0.0072475   2.677 0.007422 ** 
## Motivation         -0.5459108  0.0677174  -8.062 7.53e-16 ***
## Ethnicity           0.0641053  0.0995438   0.644 0.519582    
## Closeness          -0.1704430  0.0501558  -3.398 0.000678 ***
## Father              0.1367576  0.0745893   1.833 0.066732 .  
## Score              -0.0436223  0.0084531  -5.160 2.46e-07 ***
## Employed           -0.0329511  0.0800828  -0.411 0.680733    
## Illness             0.9289899  0.0731251  12.704  < 2e-16 ***
## Time               -0.0362226  0.0353373  -1.025 0.305338    
## Distress            0.1088221  0.0071262  15.271  < 2e-16 ***
## Siblings           -0.0501313  0.0320628  -1.564 0.117926    
## Income             -0.0005742  0.0002590  -2.217 0.026615 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for binomial family taken to be 1)
## 
##     Null deviance: 7958.7  on 8239  degrees of freedom
## Residual deviance: 7013.9  on 8220  degrees of freedom
## AIC: 7053.9
## 
## Number of Fisher Scoring iterations: 5
## 
## Enumerating 100 models..........
##                    estimate   2.5% 97.5% margpp
## (Intercept)          0.6040 -0.179  1.50  1.000
## TV                   0.0014  0.000  0.00  0.008
## `Electronic games`   0.0864  0.000  0.44  0.313
## `Social media`      -0.4358 -0.716  0.00  0.893
## `Other internet`     0.0701  0.000  0.59  0.158
## `Own computer`       0.0008  0.000  0.00  0.005
## Male                -0.6700 -0.846 -0.52  1.000
## Age                  0.0002  0.000  0.00  0.004
## BMI                  0.0200  0.000  0.04  0.901
## Motivation          -0.5646 -0.700 -0.43  1.000
## Ethnicity            0.0004  0.000  0.00  0.003
## Closeness           -0.1648 -0.269  0.00  0.966
## Father               0.1411  0.000  0.34  0.645
## Score               -0.0454 -0.062 -0.03  1.000
## Employed            -0.0001  0.000  0.00  0.003
## Illness              0.9455  0.807  1.09  1.000
## Time                -0.0001  0.000  0.00  0.004
## Distress             0.1123  0.098  0.13  1.000
## Siblings            -0.0024 -0.052  0.00  0.035
## Income              -0.0002 -0.001  0.00  0.352
## [1] "High conduct problems (parent)"
## 
## Call:
## glm(formula = reg, family = binomial(link = "logit"), data = datareg)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -1.9117  -0.6179  -0.4476  -0.2972   2.8301  
## 
## Coefficients:
##                      Estimate Std. Error z value Pr(>|z|)    
## (Intercept)         4.0670553  1.0257359   3.965 7.34e-05 ***
## TV                 -0.2633360  0.1533691  -1.717   0.0860 .  
## `Electronic games`  0.3114349  0.1224680   2.543   0.0110 *  
## `Social media`     -0.0586748  0.1636753  -0.358   0.7200    
## `Other internet`   -0.2924961  0.1683207  -1.738   0.0823 .  
## `Own computer`     -0.1835007  0.0844185  -2.174   0.0297 *  
## Male                0.1925291  0.0769889   2.501   0.0124 *  
## Age                -0.1466124  0.0692780  -2.116   0.0343 *  
## BMI                 0.0303390  0.0074286   4.084 4.43e-05 ***
## Motivation         -0.4450481  0.0690952  -6.441 1.19e-10 ***
## Ethnicity           0.2322764  0.1035056   2.244   0.0248 *  
## Closeness          -0.7668700  0.0518182 -14.799  < 2e-16 ***
## Father              0.1435148  0.0757927   1.894   0.0583 .  
## Score              -0.0577022  0.0088135  -6.547 5.87e-11 ***
## Employed           -0.0792414  0.0818294  -0.968   0.3329    
## Illness             0.4474117  0.0796301   5.619 1.92e-08 ***
## Time               -0.0765892  0.0365629  -2.095   0.0362 *  
## Distress            0.0757852  0.0072744  10.418  < 2e-16 ***
## Siblings            0.0529077  0.0317832   1.665   0.0960 .  
## Income             -0.0011376  0.0002749  -4.138 3.50e-05 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for binomial family taken to be 1)
## 
##     Null deviance: 7612.3  on 8242  degrees of freedom
## Residual deviance: 6622.9  on 8223  degrees of freedom
## AIC: 6662.9
## 
## Number of Fisher Scoring iterations: 5
## 
## Enumerating 100 models..........
##                    estimate   2.5%  97.5% margpp
## (Intercept)          2.3463  1.626  3.797  1.000
## TV                  -0.0063 -0.059  0.000  0.029
## `Electronic games`   0.0100  0.000  0.210  0.045
## `Social media`       0.0003  0.000  0.000  0.007
## `Other internet`    -0.0106 -0.213  0.000  0.051
## `Own computer`      -0.0270 -0.269  0.000  0.143
## Male                 0.2685  0.135  0.397  1.000
## Age                 -0.0050 -0.105  0.000  0.035
## BMI                  0.0279  0.014  0.042  1.000
## Motivation          -0.4648 -0.597 -0.333  1.000
## Ethnicity            0.0754  0.000  0.409  0.265
## Closeness           -0.7696 -0.868 -0.670  1.000
## Father               0.0062  0.000  0.131  0.043
## Score               -0.0519 -0.070 -0.035  1.000
## Employed            -0.0005  0.000  0.000  0.010
## Illness              0.4474  0.288  0.600  1.000
## Time                -0.0091 -0.110  0.000  0.103
## Distress             0.0767  0.063  0.091  1.000
## Siblings             0.0021  0.000  0.039  0.038
## Income              -0.0016 -0.002 -0.001  1.000
## [1] "High hyperactivity/inattention (parent)"
## 
## Call:
## glm(formula = reg, family = binomial(link = "logit"), data = datareg)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -2.0163  -0.5419  -0.3875  -0.2556   3.1191  
## 
## Coefficients:
##                      Estimate Std. Error z value Pr(>|z|)    
## (Intercept)         3.3588862  1.1429661   2.939  0.00330 ** 
## TV                 -0.2977160  0.1682845  -1.769  0.07687 .  
## `Electronic games`  0.2185224  0.1372622   1.592  0.11138    
## `Social media`     -0.0036005  0.1812408  -0.020  0.98415    
## `Other internet`   -0.2281831  0.1840546  -1.240  0.21506    
## `Own computer`     -0.0666041  0.0951035  -0.700  0.48372    
## Male                0.9980645  0.0897052  11.126  < 2e-16 ***
## Age                -0.1259598  0.0773868  -1.628  0.10360    
## BMI                 0.0030916  0.0084689   0.365  0.71507    
## Motivation         -0.7439785  0.0764145  -9.736  < 2e-16 ***
## Ethnicity           0.2715516  0.1208021   2.248  0.02458 *  
## Closeness          -0.3863673  0.0572589  -6.748 1.50e-11 ***
## Father              0.1560552  0.0840056   1.858  0.06322 .  
## Score              -0.0400035  0.0097789  -4.091 4.30e-05 ***
## Employed           -0.0845797  0.0912375  -0.927  0.35391    
## Illness             0.8281602  0.0822616  10.067  < 2e-16 ***
## Time               -0.1134947  0.0406734  -2.790  0.00526 ** 
## Distress            0.0722229  0.0079494   9.085  < 2e-16 ***
## Siblings           -0.0628901  0.0363966  -1.728  0.08400 .  
## Income             -0.0012701  0.0003058  -4.153 3.28e-05 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for binomial family taken to be 1)
## 
##     Null deviance: 6413.2  on 8242  degrees of freedom
## Residual deviance: 5549.8  on 8223  degrees of freedom
## AIC: 5589.8
## 
## Number of Fisher Scoring iterations: 5
## 
## Enumerating 100 models..........
##                     estimate   2.5%   97.5% margpp
## (Intercept)         1.624745  0.814  2.6009 1.0000
## TV                 -0.000432  0.000  0.0000 0.0017
## `Electronic games`  0.000788  0.000  0.0000 0.0077
## `Social media`      0.000000  0.000  0.0000 0.0002
## `Other internet`   -0.001429  0.000  0.0000 0.0076
## `Own computer`     -0.000170  0.000  0.0000 0.0047
## Male                1.045166  0.897  1.1924 1.0000
## Age                -0.003736 -0.058  0.0000 0.0311
## BMI                 0.000002  0.000  0.0000 0.0006
## Motivation         -0.769102 -0.917 -0.6190 1.0000
## Ethnicity           0.074355  0.000  0.4860 0.2215
## Closeness          -0.386663 -0.500 -0.2768 1.0000
## Father              0.041596  0.000  0.3130 0.1842
## Score              -0.034342 -0.055 -0.0146 1.0000
## Employed           -0.000191  0.000  0.0000 0.0044
## Illness             0.830373  0.669  0.9931 1.0000
## Time               -0.068419 -0.188  0.0000 0.5899
## Distress            0.074603  0.060  0.0895 1.0000
## Siblings           -0.006353 -0.096  0.0000 0.0890
## Income             -0.001362 -0.002 -0.0008 1.0000
## [1] "High peer problems (parent)"
## 
## Call:
## glm(formula = reg, family = binomial(link = "logit"), data = datareg)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -2.0277  -0.7381  -0.5671  -0.3632   2.4387  
## 
## Coefficients:
##                      Estimate Std. Error z value Pr(>|z|)    
## (Intercept)         1.7764381  0.8935963   1.988   0.0468 *  
## TV                  0.2005313  0.1353101   1.482   0.1383    
## `Electronic games`  0.4505881  0.1086880   4.146 3.39e-05 ***
## `Social media`     -0.6204424  0.1453357  -4.269 1.96e-05 ***
## `Other internet`    0.6227271  0.1429684   4.356 1.33e-05 ***
## `Own computer`     -0.0337325  0.0768490  -0.439   0.6607    
## Male               -0.0863241  0.0673271  -1.282   0.1998    
## Age                -0.0977807  0.0601441  -1.626   0.1040    
## BMI                 0.0448875  0.0064903   6.916 4.64e-12 ***
## Motivation         -0.2869279  0.0617294  -4.648 3.35e-06 ***
## Ethnicity          -0.0845677  0.0869307  -0.973   0.3306    
## Closeness          -0.2209562  0.0456414  -4.841 1.29e-06 ***
## Father              0.0808871  0.0678299   1.192   0.2331    
## Score              -0.0443060  0.0075736  -5.850 4.91e-09 ***
## Employed           -0.1606559  0.0717272  -2.240   0.0251 *  
## Illness             0.5690950  0.0698149   8.151 3.59e-16 ***
## Time               -0.0586955  0.0320328  -1.832   0.0669 .  
## Distress            0.0708151  0.0065875  10.750  < 2e-16 ***
## Siblings           -0.0981465  0.0289544  -3.390   0.0007 ***
## Income             -0.0010676  0.0002329  -4.583 4.57e-06 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for binomial family taken to be 1)
## 
##     Null deviance: 9114.8  on 8243  degrees of freedom
## Residual deviance: 8307.1  on 8224  degrees of freedom
## AIC: 8347.1
## 
## Number of Fisher Scoring iterations: 4
## 
## Enumerating 100 models..........
##                    estimate   2.5%   97.5% margpp
## (Intercept)          0.3605 -0.437  1.8326   1.00
## TV                   0.0114  0.000  0.2216   0.05
## `Electronic games`   0.3987  0.213  0.5837   1.00
## `Social media`      -0.5248 -0.784 -0.2662   1.00
## `Other internet`     0.6852  0.413  0.9586   1.00
## `Own computer`      -0.0005  0.000  0.0000   0.01
## Male                -0.0049 -0.099  0.0000   0.05
## Age                 -0.0059 -0.106  0.0000   0.06
## BMI                  0.0457  0.033  0.0584   1.00
## Motivation          -0.2848 -0.403 -0.1649   1.00
## Ethnicity           -0.0011  0.000  0.0000   0.02
## Closeness           -0.2310 -0.320 -0.1442   1.00
## Father               0.0029  0.000  0.0453   0.04
## Score               -0.0443 -0.058 -0.0300   1.00
## Employed            -0.0118 -0.172  0.0000   0.09
## Illness              0.5775  0.441  0.7125   1.00
## Time                -0.0022 -0.044  0.0000   0.04
## Distress             0.0738  0.061  0.0867   1.00
## Siblings            -0.0748 -0.144  0.0000   0.82
## Income              -0.0013 -0.002 -0.0009   1.00
## [1] "Low pro-sociality (parent)"
## 
## Call:
## glm(formula = reg, family = binomial(link = "logit"), data = datareg)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -1.2532  -0.4434  -0.3458  -0.2614   2.8413  
## 
## Coefficients:
##                      Estimate Std. Error z value Pr(>|z|)    
## (Intercept)         0.9882956  1.3569900   0.728 0.466430    
## TV                 -0.1164941  0.2009520  -0.580 0.562110    
## `Electronic games`  0.5882050  0.1658365   3.547 0.000390 ***
## `Social media`     -0.3420938  0.2192110  -1.561 0.118626    
## `Other internet`    0.1265936  0.2153927   0.588 0.556711    
## `Own computer`     -0.1972771  0.1086199  -1.816 0.069337 .  
## Male                0.4920521  0.1044782   4.710 2.48e-06 ***
## Age                -0.0419043  0.0920768  -0.455 0.649036    
## BMI                -0.0055014  0.0103768  -0.530 0.595995    
## Motivation         -0.4294721  0.0920437  -4.666 3.07e-06 ***
## Ethnicity          -0.1065186  0.1365415  -0.780 0.435321    
## Closeness          -0.5894188  0.0670178  -8.795  < 2e-16 ***
## Father              0.0089735  0.1034699   0.087 0.930889    
## Score               0.0044042  0.0115281   0.382 0.702434    
## Employed           -0.0172046  0.1098222  -0.157 0.875514    
## Illness             0.4014871  0.1023072   3.924 8.70e-05 ***
## Time               -0.0516132  0.0488900  -1.056 0.291105    
## Distress            0.0398713  0.0097648   4.083 4.44e-05 ***
## Siblings            0.1375057  0.0414139   3.320 0.000899 ***
## Income             -0.0004492  0.0003557  -1.263 0.206627    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for binomial family taken to be 1)
## 
##     Null deviance: 4622.9  on 8242  degrees of freedom
## Residual deviance: 4298.7  on 8223  degrees of freedom
## AIC: 4338.7
## 
## Number of Fisher Scoring iterations: 5
## 
## Enumerating 100 models..........
##                      estimate  2.5% 97.5%  margpp
## (Intercept)        -0.5135630 -1.24  0.30 1.00000
## TV                 -0.0000762  0.00  0.00 0.00011
## `Electronic games`  0.5577833  0.25  0.86 0.99996
## `Social media`     -0.1779393 -0.70  0.00 0.38173
## `Other internet`    0.0259494  0.00  0.42 0.07021
## `Own computer`     -0.0113011 -0.22  0.00 0.05732
## Male                0.5497210  0.34  0.76 1.00000
## Age                 0.0000000  0.00  0.00 0.00008
## BMI                -0.0000043  0.00  0.00 0.00047
## Motivation         -0.4213178 -0.60 -0.24 1.00000
## Ethnicity          -0.0000031  0.00  0.00 0.00010
## Closeness          -0.5811137 -0.71 -0.45 1.00000
## Father             -0.0000116  0.00  0.00 0.00017
## Score               0.0000000  0.00  0.00 0.00007
## Employed            0.0000000  0.00  0.00 0.00019
## Illness             0.3877778  0.00  0.60 0.96117
## Time               -0.0005795  0.00  0.00 0.01460
## Distress            0.0442213  0.03  0.06 1.00000
## Siblings            0.1767598  0.11  0.25 1.00000
## Income             -0.0000001  0.00  0.00 0.00023

2.5.2 Specification curves

y_labels = round(c(1/2, 1, 2, 3, 4), 2); names(y_labels) = log(y_labels)  # y scale as odds ratio

bsca_logit = list()
for (idy in 1:length(yvars)) {
  yvar = yvars[idy]; yname = names(yvars)[idy]
  cat("\n#### ", 'Outcome: ', yname, '\n')
  single_bsca(
    ms_logit[[yname]], coefidx=idx+1, maxmodels=maxmodels,
    x.labels=x_names, var.labels=names(cvars), y.labels=y_labels,
    legend.cex=legend_size
  )
  bsca_logit[[yname]] = recordPlot()
}

2.5.2.1 Outcome: Depressed (adolescent)

#### Outcome: Low self-esteem (adolescent) #### Outcome: High total difficulties (parent) #### Outcome: High emotional problems (parent) #### Outcome: High conduct problems (parent) #### Outcome: High hyperactivity/inattention (parent) #### Outcome: High peer problems (parent) #### Outcome: Low pro-sociality (parent)

2.5.2.2 Combined main

supplement$bsca_logit = plot_grid(plotlist=bsca_logit[1:4], ncol=2, labels='auto')
ggsave(
  file.path(plot_path, 'mcs_bsca_logit.png'), 
  supplement$bsca_logit,
  height=6, width=8
)
supplement$bsca_logit

2.5.2.3 Combined parent

supplement$bsca_parent_logit = plot_grid(plotlist=bsca_logit[5:8], ncol=2, labels='auto')
ggsave(
  file.path(plot_path, 'mcs_bsca_parent_logit.png'), 
  supplement$bsca_parent_logit,
  height=6, width=8
)
supplement$bsca_parent_logit

2.5.3 Using full model space

For computational efficiency, we used the most likely linear models above. The results go through if sampling from the full model space, as shown for one outcome below.

Results for high total difficulties above:

single_bsca(ms_logit$`High total difficulties (parent)`, coefidx=2:6)

Results for full model space:

yvar = yvars[3]
datareg = na.omit(data[c(yvar, x_vars, cvars)])
names(datareg) = c('y', x_names, names(cvars))
fit_bas <- bas.glm(
  y~., data=datareg, family=binomial(link='logit'), 
  betaprior=bic.prior(), modelprior=beta.binomial(),
  method='MCMC', n.models=200
)
single_bsca(fit_bas, coefidx=2:6)

2.6 SUBGROUP ANALYSIS

2.6.1 Logit

We perform a gender subgroup analysis. The variables are parameterized as described in the paper. Interaction terms are included only if the corresponding main variable is included. BMA is done through Gibbs sampling.

idg="Male"
{
  options(na.action='na.pass')
  x.reg = model.matrix(~ ., x[,idx])[, -1]
  colnames(x.reg) = x_names
}
ms_inter = list(); coef_inter = list()

for (idy in 1:length(yvars)) {
  yname = names(yvars)[idy]
  message(yname)
  
  datareg = na.omit(data[c(yvars[idy], x_vars, cvars)])
  names(datareg) = c('y', x_names, names(cvars))
  
  # treatments
  idt = colnames(x.reg)
  datareg[idt] = datareg[idt] - 1/2
  # group
  g = datareg[[idg]]; rho = sum(g == 1)/length(g)
  datareg[[idg]] = ifelse(g == 1, 1-rho, -rho)
  # interaction 
  inter = datareg[idt]*datareg[[idg]]
  colnames(inter) = paste0(colnames(inter), " × male")
  
  d = mombf:::createDesign(y ~ ., cbind(datareg, inter))
  p=length(d$constraints); pi=ncol(inter)
  d$constraints[(p-pi+1):p] = 1:pi+1
  ms_inter[[yname]] = mombf:::modelSelection(
    d$y, d$x, includevars=1, family="binomial", 
    priorDelta=modelbbprior(1,1), priorCoef=bicprior(), priorGroup=bicprior(),
    niter=NITER_MCS, groups=d$groups, constraints=d$constraints,
  )
  coef_inter[[yname]] = coef(ms_inter[[yname]])
}
## Depressed (adolescent)
## Greedy searching posterior mode... Done.
## Running Gibbs sampler........... Done.
## Low self-esteem (adolescent)
## Greedy searching posterior mode... Done.
## Running Gibbs sampler........... Done.
## High total difficulties (parent)
## Greedy searching posterior mode... Done.
## Running Gibbs sampler........... Done.
## High emotional problems (parent)
## Greedy searching posterior mode... Done.
## Running Gibbs sampler........... Done.
## High conduct problems (parent)
## Greedy searching posterior mode... Done.
## Running Gibbs sampler........... Done.
## High hyperactivity/inattention (parent)
## Greedy searching posterior mode... Done.
## Running Gibbs sampler........... Done.
## High peer problems (parent)
## Greedy searching posterior mode... Done.
## Running Gibbs sampler........... Done.
## Low pro-sociality (parent)
## Greedy searching posterior mode... Done.
## Running Gibbs sampler........... Done.

The gender effect is always zero.

supplement$mbsca_inter = multi_bsca(
  coef_inter, ms=ms_inter, conversion=exp,  y.scale='Odds ratio', 
  treatments=tail(rownames(coef_inter$`Depressed (adolescent)`), n=length(x_names)),
  extract.color=TRUE
) + geom_hline(yintercept=1, lwd=0.2) + ylim(0.8, 1.5)
supplement$mbsca_inter

2.6.2 Raw data

Yet, there is a higher correlation between social media use and self-reported regression for females than males.

plotdf = data[!is.na(data$depressed), ] %>% 
  rename(SocialMediaUsage="fcsome00r", Male="fccsex00r") %>%
  mutate_at("Male", as.logical) %>%
  mutate_at("depressed", as.numeric)

# plotdf %>% 
#   select(Male, SocialMediaUsage, depressed) %>% 
#   drop_na() %>% 
#   group_by(Male) %>% 
#   summarise(cor=cor(SocialMediaUsage, depressed, method="spearman"))

plotdf %>%
  group_by(Male, SocialMediaUsage) %>%
  summarise(depressed = mean(depressed)) %>%
  ggplot(aes(x=SocialMediaUsage, y=depressed, color=Male)) +
  geom_col(position=position_dodge())
## `summarise()` has grouped output by 'Male'. You can override using the `.groups` argument.
## Warning: Removed 2 rows containing missing values (geom_col).

This correlation is even stronger when using the continuous outcome variable.

# plotdf %>% 
#   select(Male, SocialMediaUsage, depression) %>% 
#   drop_na() %>% 
#   group_by(Male) %>% 
#   summarise(cor=cor(SocialMediaUsage, depression, method="spearman"))

plotdf %>%
  group_by(Male, SocialMediaUsage) %>%
  summarise(depression = mean(depression)) %>%
  ggplot(aes(x=SocialMediaUsage, y=depression, color=Male)) +
  geom_col(position=position_dodge())
## `summarise()` has grouped output by 'Male'. You can override using the `.groups` argument.
## Warning: Removed 2 rows containing missing values (geom_col).

2.6.3 Linear

We therefore also run the subgroup analysis with the original variables (normalized to 1-10) and a linear model. Here we find a gender effect for depression, in a simple GLM regression. We perform a BMA analysis on all outcomes in the main analysis file.

idg="Male"
datareg = na.omit(data[c("depression", x_vars, cvars)])
datareg$depression = datareg$depression/max(datareg$depression)
names(datareg) = c('y', x_names, names(cvars))

# treatments
idt = x_names
datareg[idt] = datareg[idt] - 1/2
# group
g = datareg[[idg]]; rho = sum(g == 1)/length(g)
datareg[[idg]] = ifelse(g == 1, 1-rho, -rho)
# interaction 
inter = datareg[idt]*datareg[[idg]]
colnames(inter) = paste0(colnames(inter), ":male")

fit = lm(y ~ ., data=c(datareg, inter))
summary(fit)
## 
## Call:
## lm(formula = y ~ ., data = c(datareg, inter))
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -0.54199 -0.11653 -0.02987  0.08151  0.88777 
## 
## Coefficients:
##                           Estimate Std. Error t value Pr(>|t|)    
## (Intercept)              8.225e-01  6.586e-02  12.488  < 2e-16 ***
## TV                       7.365e-03  1.011e-02   0.728 0.466334    
## `Electronic games`       1.188e-02  8.123e-03   1.463 0.143605    
## `Social media`           5.190e-02  1.070e-02   4.852 1.24e-06 ***
## `Other internet`         5.704e-02  1.097e-02   5.197 2.07e-07 ***
## `Own computer`          -4.956e-03  5.657e-03  -0.876 0.381052    
## Male                    -1.247e-01  1.078e-02 -11.563  < 2e-16 ***
## Age                      5.188e-03  4.446e-03   1.167 0.243328    
## BMI                      3.804e-03  5.060e-04   7.517 6.18e-14 ***
## Motivation              -1.632e-01  4.670e-03 -34.942  < 2e-16 ***
## Ethnicity               -1.691e-02  6.659e-03  -2.539 0.011124 *  
## Closeness               -6.930e-02  3.401e-03 -20.376  < 2e-16 ***
## Father                   2.582e-04  5.176e-03   0.050 0.960217    
## Score                    1.985e-03  5.518e-04   3.597 0.000324 ***
## Employed                -4.896e-03  5.487e-03  -0.892 0.372271    
## Illness                  4.369e-02  5.597e-03   7.806 6.62e-15 ***
## Time                    -3.276e-03  2.380e-03  -1.376 0.168754    
## Distress                 1.872e-03  5.239e-04   3.574 0.000354 ***
## Siblings                -4.679e-03  2.154e-03  -2.173 0.029844 *  
## Income                   1.089e-05  1.643e-05   0.663 0.507411    
## `TV:male`                9.166e-03  2.018e-02   0.454 0.649709    
## `Electronic games:male`  1.361e-03  1.610e-02   0.085 0.932652    
## `Social media:male`     -1.312e-01  2.059e-02  -6.371 1.97e-10 ***
## `Other internet:male`   -9.027e-02  2.181e-02  -4.139 3.52e-05 ***
## `Own computer:male`     -4.899e-03  1.118e-02  -0.438 0.661356    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.181 on 8326 degrees of freedom
## Multiple R-squared:  0.3337, Adjusted R-squared:  0.3318 
## F-statistic: 173.7 on 24 and 8326 DF,  p-value: < 2.2e-16

2.7 SAVE DATA

Save the data for use in bsca_main.Rmd.

save(
  data, yvars, y_cont, x_vars, x_names, cvars, pp_lin, supplement,
  file=file.path(PATH, 'data/export/mcs.Rdata')
)